<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Casts\Attribute;
class Attendance extends Model
{
    use HasFactory;
    use SoftDeletes;

    protected $guarded = [];

    public function employees()
    {
        return $this->belongsToMany(Employee::class);
    }
    
    public function employees_gamaeya()
    {
        return $this->belongsToMany(Employee::class, 'attendance_employee_gamaeya');
    }

    public function employees_half_day()
    {
        return $this->belongsToMany(Employee::class, 'attendance_employee_half_day');
    }

    public function lands()
    {
        return $this->belongsToMany(Land::class);
    }
    public function getDayTypeAttribute($value)
    {
        return match ($value) {
            'full_day' => 'يوم كامل',
            'half_day' => 'نصف يوم',
            default => $value,
        };
    }

    public function workType()
    {
        return $this->belongsTo(WorkType::class);
    }
}
