56 lines
1.6 KiB
PHP
56 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Domain\Reservations\Models;
|
|
|
|
use App\Domain\Inventory\Models\SnipeAsset;
|
|
use App\Domain\Operations\Models\HandoverRecord;
|
|
use App\Domain\Reservations\Enums\ReservationItemStatus;
|
|
use Carbon\CarbonImmutable;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
/**
|
|
* @property ReservationItemStatus $status
|
|
* @property CarbonImmutable $starts_at
|
|
* @property CarbonImmutable $ends_at
|
|
* @property SnipeAsset $asset
|
|
*/
|
|
class ReservationItem extends Model
|
|
{
|
|
protected $fillable = [
|
|
'reservation_id', 'snipe_asset_id', 'starts_at', 'ends_at', 'status',
|
|
'delivered_at', 'returned_at', 'checkout_reference', 'checkin_reference',
|
|
'condition_out', 'condition_in', 'notes',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'status' => ReservationItemStatus::class,
|
|
'starts_at' => 'immutable_datetime',
|
|
'ends_at' => 'immutable_datetime',
|
|
'delivered_at' => 'immutable_datetime',
|
|
'returned_at' => 'immutable_datetime',
|
|
];
|
|
}
|
|
|
|
/** @return BelongsTo<Reservation, $this> */
|
|
public function reservation(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Reservation::class);
|
|
}
|
|
|
|
/** @return BelongsTo<SnipeAsset, $this> */
|
|
public function asset(): BelongsTo
|
|
{
|
|
return $this->belongsTo(SnipeAsset::class, 'snipe_asset_id');
|
|
}
|
|
|
|
/** @return HasMany<HandoverRecord, $this> */
|
|
public function handoverRecords(): HasMany
|
|
{
|
|
return $this->hasMany(HandoverRecord::class);
|
|
}
|
|
}
|