Merge remote-tracking branch 'origin/master' into Development
This commit is contained in:
@@ -112,6 +112,11 @@ public function segments(): BelongsToMany
|
||||
->wherePivot('active', true);
|
||||
}
|
||||
|
||||
public function attachedSegments(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(\App\Models\Segment::class);
|
||||
}
|
||||
|
||||
public function account(): HasOne
|
||||
{
|
||||
// Use latestOfMany to always surface newest account snapshot if multiple exist.
|
||||
@@ -130,6 +135,18 @@ public function documents(): MorphMany
|
||||
return $this->morphMany(\App\Models\Document::class, 'documentable');
|
||||
}
|
||||
|
||||
public function fieldJobs(): HasMany
|
||||
{
|
||||
return $this->hasMany(\App\Models\FieldJob::class);
|
||||
}
|
||||
|
||||
public function latestObject(): HasOne
|
||||
{
|
||||
return $this->hasOne(\App\Models\CaseObject::class)
|
||||
->whereNull('deleted_at')
|
||||
->latest();
|
||||
}
|
||||
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::created(function (Contract $contract): void {
|
||||
|
||||
@@ -24,6 +24,8 @@ class FieldJob extends Model
|
||||
'priority',
|
||||
'notes',
|
||||
'address_snapshot ',
|
||||
'last_activity',
|
||||
'added_activity'
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
@@ -31,6 +33,8 @@ class FieldJob extends Model
|
||||
'completed_at' => 'datetime',
|
||||
'cancelled_at' => 'datetime',
|
||||
'priority' => 'boolean',
|
||||
'last_activity' => 'datetime',
|
||||
'added_activity' => 'boolean',
|
||||
'address_snapshot ' => 'array',
|
||||
];
|
||||
|
||||
@@ -90,7 +94,8 @@ public function user(): BelongsTo
|
||||
|
||||
public function contract(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Contract::class, 'contract_id');
|
||||
return $this->belongsTo(Contract::class, 'contract_id')
|
||||
->where('active', true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user