40 lines
1,010 B
PHP
40 lines
1,010 B
PHP
<?php
|
|
|
|
namespace App\Modules\History\Models;
|
|
|
|
use App\Models\User;
|
|
use App\Modules\Client\Models\Client;
|
|
use Database\Factories\HistoryEntryFactory;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class HistoryEntry extends Model
|
|
{
|
|
use HasFactory, SoftDeletes;
|
|
|
|
protected $fillable = ['client_id', 'type', 'body', 'author_id', 'updated_by'];
|
|
|
|
protected $casts = ['type' => HistoryEntryType::class];
|
|
|
|
public function client(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Client::class);
|
|
}
|
|
|
|
public function author(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class, 'author_id');
|
|
}
|
|
|
|
public function updatedBy(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class, 'updated_by');
|
|
}
|
|
|
|
protected static function newFactory(): HistoryEntryFactory
|
|
{
|
|
return HistoryEntryFactory::new();
|
|
}
|
|
}
|