<?php

namespace App\Models\Office;

use App\Models\User;
use App\Traits\BelongsToStore;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class Handover extends Model
{
    use BelongsToStore;

    const UPDATED_AT = null;

    protected $fillable = [
        'store_id', 'shift_date', 'shift_type', 'handover_user_id',
        'receiver_user_id', 'content', 'issues', 'status', 'confirmed_at',
    ];

    protected function casts(): array
    {
        return [
            'shift_type' => 'integer',
            'status' => 'integer',
            'shift_date' => 'date',
            'confirmed_at' => 'datetime',
        ];
    }

    public function handoverUser(): BelongsTo
    {
        return $this->belongsTo(User::class, 'handover_user_id');
    }

    public function receiverUser(): BelongsTo
    {
        return $this->belongsTo(User::class, 'receiver_user_id');
    }
}
