59 lines
1.5 KiB
PHP
59 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Domains\Event\Models;
|
|
|
|
use App\Domains\Auth\Models\User;
|
|
use App\Domains\Tenant\Models\Tenant;
|
|
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
#[Fillable([
|
|
'tenant_code',
|
|
'source_event_date_id',
|
|
'destination_event_date_id',
|
|
'created_by_user_id',
|
|
'previous_date',
|
|
'new_date',
|
|
])]
|
|
class EventDateReschedule extends Model
|
|
{
|
|
public $timestamps = false;
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'source_event_date_id' => 'integer',
|
|
'destination_event_date_id' => 'integer',
|
|
'created_by_user_id' => 'integer',
|
|
'previous_date' => 'date:Y-m-d',
|
|
'new_date' => 'date:Y-m-d',
|
|
'created_at' => 'datetime',
|
|
];
|
|
}
|
|
|
|
/** @return BelongsTo<Tenant, $this> */
|
|
public function tenant(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Tenant::class, 'tenant_code', 'codigo');
|
|
}
|
|
|
|
/** @return BelongsTo<EventDate, $this> */
|
|
public function sourceEventDate(): BelongsTo
|
|
{
|
|
return $this->belongsTo(EventDate::class, 'source_event_date_id');
|
|
}
|
|
|
|
/** @return BelongsTo<EventDate, $this> */
|
|
public function destinationEventDate(): BelongsTo
|
|
{
|
|
return $this->belongsTo(EventDate::class, 'destination_event_date_id');
|
|
}
|
|
|
|
/** @return BelongsTo<User, $this> */
|
|
public function createdBy(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class, 'created_by_user_id')->withTrashed();
|
|
}
|
|
}
|