57 lines
1.5 KiB
PHP
57 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Traits\Uuid;
|
|
use Illuminate\Database\Eloquent\Factories\BelongsToManyRelationship;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
|
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
|
|
use Illuminate\Database\Eloquent\Relations\HasOne;
|
|
use Illuminate\Database\Eloquent\Relations\HasOneOrManyThrough;
|
|
use Illuminate\Database\Eloquent\Relations\MorphOne;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class Contract extends Model
|
|
{
|
|
/** @use HasFactory<\Database\Factories\ContractFactory> */
|
|
use HasFactory;
|
|
use Uuid;
|
|
use SoftDeletes;
|
|
|
|
protected $fillable = [
|
|
'reference',
|
|
'start_date',
|
|
'end_date',
|
|
'client_case_id',
|
|
'type_id',
|
|
'description'
|
|
];
|
|
|
|
protected $hidden = [
|
|
'id',
|
|
'client_case_id',
|
|
'type_id'
|
|
];
|
|
|
|
public function type(): BelongsTo
|
|
{
|
|
return $this->belongsTo(\App\Models\ContractType::class, 'type_id');
|
|
}
|
|
|
|
public function clientCase(): BelongsTo
|
|
{
|
|
return $this->belongsTo(\App\Models\ClientCase::class)
|
|
->with(['person']);
|
|
}
|
|
|
|
public function segments(): BelongsToMany {
|
|
return $this->belongsToMany(\App\Models\Segment::class)
|
|
->withPivot('active', 'created_at')
|
|
->wherePivot('active', true);
|
|
}
|
|
|
|
}
|