'datetime', 'attachments_count' => 'integer' ]; /** * Get the client associated with the intervention. */ public function client(): BelongsTo { return $this->belongsTo(Client::class); } /** * Get the deceased associated with the intervention. */ public function deceased(): BelongsTo { return $this->belongsTo(Deceased::class); } /** * Get the location associated with the intervention. */ public function location(): BelongsTo { return $this->belongsTo(ClientLocation::class); } /** * Get the practitioners assigned to the intervention. */ public function practitioners(): BelongsToMany { return $this->belongsToMany(Thanatopractitioner::class, 'intervention_practitioner', 'intervention_id', 'practitioner_id') ->withPivot('role', 'assigned_at') ->withTimestamps(); } /** * Alias for practitioners relationship (for backward compatibility). */ public function assignedPractitioner(): BelongsToMany { return $this->practitioners(); } /** * Get the principal practitioner assigned to the intervention. */ public function principalPractitioner(): BelongsToMany { return $this->belongsToMany(Thanatopractitioner::class, 'intervention_practitioner', 'intervention_id', 'practitioner_id') ->wherePivot('role', 'principal') ->withPivot('role', 'assigned_at') ->withTimestamps(); } /** * Get the assistant practitioners assigned to the intervention. */ public function assistantPractitioners(): BelongsToMany { return $this->belongsToMany(Thanatopractitioner::class, 'intervention_practitioner', 'intervention_id', 'practitioner_id') ->wherePivot('role', 'assistant') ->withPivot('role', 'assigned_at') ->withTimestamps(); } /** * Get the user who created the intervention. */ public function creator(): BelongsTo { return $this->belongsTo(User::class, 'created_by'); } /** * Get the attachments for the intervention. */ public function attachments(): HasMany { return $this->hasMany(InterventionAttachment::class); } /** * Get the notifications for the intervention. */ public function notifications(): HasMany { return $this->hasMany(InterventionNotification::class); } }