46 lines
1 KiB
PHP
46 lines
1 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\Relations\BelongsToMany;
|
|
|
|
class CalendarSlot extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $fillable = [
|
|
'trip_id',
|
|
'name',
|
|
'datetime_start',
|
|
'datetime_end',
|
|
'slot_date',
|
|
'slot_order',
|
|
];
|
|
|
|
protected $casts = [
|
|
'datetime_start' => 'datetime',
|
|
'datetime_end' => 'datetime',
|
|
'slot_date' => 'date',
|
|
];
|
|
|
|
public function trip(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Trip::class);
|
|
}
|
|
|
|
public function plannableItems(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(PlannableItem::class, 'planned_items')
|
|
->withPivot('sort_order')
|
|
->withTimestamps()
|
|
->orderBy('planned_items.sort_order');
|
|
}
|
|
|
|
public function plannedItems()
|
|
{
|
|
return $this->hasMany(PlannedItem::class);
|
|
}
|
|
}
|