<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;

class Staff extends Model
{
    protected $fillable = [
        'branch_id',
        'name',
        'employee_code',
        'phone',
        'email',
        'designation',
        'department',
        'salary',
        'commission_percent',
        'incentive_amount',
        'status',
        'join_date',
        'kpi_target_amount',
        'notes',
        'nfc_uid',
        'office_start_time',
        'office_end_time',
        'late_grace_minutes',
    ];

    protected $casts = [
        'salary' => 'decimal:2',
        'commission_percent' => 'decimal:2',
        'incentive_amount' => 'decimal:2',
        'kpi_target_amount' => 'decimal:2',
        'join_date' => 'date',
        'late_grace_minutes' => 'integer',
    ];

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

    public function attendances(): HasMany
    {
        return $this->hasMany(StaffAttendance::class);
    }
}
