59 lines
1.2 KiB
PHP
59 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Models\Registries;
|
|
|
|
use App\Models\Asset;
|
|
use App\Support\HasObjectsTrait;
|
|
use App\Support\RelationValuesTrait;
|
|
use App\Support\UuidScopeTrait;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\MorphToMany;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class Entry extends Model {
|
|
use UuidScopeTrait, SoftDeletes, HasObjectsTrait, RelationValuesTrait;
|
|
|
|
protected $table = 'registry_entries';
|
|
|
|
protected $dates = [
|
|
'active_since',
|
|
'active_till'
|
|
];
|
|
|
|
protected $fillable = [
|
|
'uuid',
|
|
'registry_id',
|
|
'category_id',
|
|
'asset_id',
|
|
'number',
|
|
'name',
|
|
'active_since',
|
|
'active_till'
|
|
];
|
|
|
|
protected $hidden = [
|
|
'id'
|
|
];
|
|
|
|
|
|
public function registry(): BelongsTo {
|
|
return $this->belongsTo(Registry::class);
|
|
}
|
|
|
|
public function category(): BelongsTo {
|
|
return $this->belongsTo(Category::class);
|
|
}
|
|
|
|
public function asset(): BelongsTo {
|
|
return $this->belongsTo(Asset::class);
|
|
}
|
|
|
|
public function operations(): MorphToMany {
|
|
return $this->objects()->reorder()->applyOrders(['order-date' => 'desc']);
|
|
}
|
|
|
|
|
|
|
|
}
|