<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use OwenIt\Auditing\Auditable as AuditableTrait;
use OwenIt\Auditing\Contracts\Auditable;

class ScheduleShift extends Model implements Auditable
{
    use HasFactory, SoftDeletes, AuditableTrait;

    /**
     * The attributes that are NOT mass assignable.
     *
     */
    protected $guarded = [
        'deleted_at',
    ];

    /**
     * The attributes that should be cast.
     *
     * @var array<string, string>
     */
    protected $casts = [
        'created_at' => 'datetime',
        'updated_at' => 'datetime',
        'deleted_at' => 'datetime',
    ];

    protected $appends = [
        'lunch_break',
        'cws_lunch_break',
        'shifting_lunch_break',
    ];

    public function getLunchBreakAttribute()
    {
        return LunchBreakSetting::where(['schedule_from_time' => $this->from_time, 'schedule_to_time' => $this->to_time])->select('start_break_time','end_break_time')->first();
    }

    public function getCwsLunchBreakAttribute()
    {
        return LunchBreakSetting::where(['schedule_from_time' => $this->cws_from_time, 'schedule_to_time' => $this->cws_to_time])->select('start_break_time','end_break_time')->first();
    }
    public function getShiftingLunchBreakAttribute()
    {
        return LunchBreakSetting::where(['schedule_from_time' => $this->shifting_from_time, 'schedule_to_time' => $this->shifting_to_time])->select('start_break_time','end_break_time')->first();
    }




}
