64 lines
1.4 KiB
PHP
64 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class Activity extends Model
|
|
{
|
|
/** @use HasFactory<\Database\Factories\ActivityFactory> */
|
|
use HasFactory;
|
|
use SoftDeletes;
|
|
|
|
protected $fillable = [
|
|
'due_date',
|
|
'amount',
|
|
'note',
|
|
'action_id',
|
|
'user_id',
|
|
'decision_id',
|
|
'contract_id'
|
|
];
|
|
|
|
protected $hidden = [
|
|
'action_id',
|
|
'decision_id',
|
|
'client_case_id',
|
|
'user_id',
|
|
'contract_id'
|
|
];
|
|
|
|
protected static function booted(){
|
|
static::creating(function (Activity $activity) {
|
|
if(!isset($activity->user_id)){
|
|
$activity->user_id = auth()->id();
|
|
}
|
|
});
|
|
}
|
|
|
|
|
|
|
|
public function action(): BelongsTo
|
|
{
|
|
return $this->belongsTo(\App\Models\Action::class);
|
|
}
|
|
|
|
public function decision(): BelongsTo
|
|
{
|
|
return $this->belongsTo(\App\Models\Decision::class);
|
|
}
|
|
|
|
public function clientCase(): BelongsTo
|
|
{
|
|
return $this->belongsTo(\App\Models\ClientCase::class);
|
|
}
|
|
|
|
public function contract(): BelongsTo|null
|
|
{
|
|
return $this->belongsTo(\App\Models\Contract::class);
|
|
}
|
|
}
|