<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class CourierSalary extends Model
{
    protected $fillable = [
        'courier_id',
        'month',
        'year',
        'total_deliveries',
        'base_salary',
        'bonus',
        'total_salary',
        'status',
        'paid_at',
    ];

    protected $casts = [
        'paid_at' => 'datetime',
    ];

    public function courier()
    {
        return $this->belongsTo(User::class, 'courier_id');
    }

    public function getMonthNameAttribute(): string
    {
        return \Carbon\Carbon::create()->month($this->month)->translatedFormat('F');
    }
}