-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVerificationReport.php
More file actions
60 lines (50 loc) · 1.93 KB
/
Copy pathVerificationReport.php
File metadata and controls
60 lines (50 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
namespace App\Models;
use App\Services\EmailTemplateService;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
/**
* A verification or site-visit report filed by a staff member.
*
* Status transitions (staff-driven):
* DRAFT → SUBMITTED → APPROVED | REJECTED
*
* Model observer: when status changes to SUBMITTED or APPROVED, the client
* receives an automated email via EmailTemplateService ('report-released' /
* 'report-approved' slugs).
*/
class VerificationReport extends Model
{
protected $fillable = [
'order_id', 'project_id', 'staff_id',
'summary', 'findings', 'recommendations',
'status', // DRAFT | SUBMITTED | APPROVED | REJECTED
'attachments',
];
protected $casts = [
'attachments' => 'array',
];
// ── Relationships ─────────────────────────────────────────────────────────
public function order(): BelongsTo
{
return $this->belongsTo(VerificationOrder::class, 'order_id');
}
public function project(): BelongsTo
{
return $this->belongsTo(Project::class, 'project_id');
}
public function staff(): BelongsTo
{
return $this->belongsTo(Staff::class, 'staff_id');
}
// ── Observer ──────────────────────────────────────────────────────────────
protected static function booted(): void
{
static::updated(function (VerificationReport $report) {
// On status change to SUBMITTED or APPROVED, resolve the client
// from $report->order()->with('client') and dispatch the
// appropriate email template via EmailTemplateService
// ...
});
}
}