<?php

namespace App\Models;

use App\Traits\BelongsToTenant;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class Shift extends Model
{
    use BelongsToTenant, SoftDeletes;

    protected $fillable = ['tenant_id', 'branch_id', 'department_id', 'name', 'code', 'type', 'start_time', 'end_time', 'second_start_time', 'second_end_time', 'grace_minutes', 'break_minutes', 'minimum_overtime_minutes', 'overtime_multiplier', 'applicable_days', 'late_rule', 'early_leave_rule', 'overtime_rule', 'is_active'];

    protected $casts = ['applicable_days' => 'array', 'late_rule' => 'array', 'early_leave_rule' => 'array', 'overtime_rule' => 'array', 'is_active' => 'boolean', 'overtime_multiplier' => 'decimal:3'];

    public function branch()
    {
        return $this->belongsTo(Branch::class);
    }

    public function department()
    {
        return $this->belongsTo(Department::class);
    }

    public function assignments()
    {
        return $this->hasMany(ShiftAssignment::class);
    }
}
