59 lines
1.4 KiB
PHP
59 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class PayrollPeriod extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $fillable = [
|
|
'tenant_id',
|
|
'month',
|
|
'year',
|
|
'status',
|
|
'total_gross',
|
|
'total_deductions',
|
|
'total_net',
|
|
'confirmed_by',
|
|
'confirmed_at',
|
|
'notes',
|
|
'created_by',
|
|
];
|
|
|
|
protected $casts = [
|
|
'confirmed_at' => 'datetime',
|
|
'total_gross' => 'decimal:0',
|
|
'total_deductions' => 'decimal:0',
|
|
'total_net' => 'decimal:0',
|
|
];
|
|
|
|
public function tenant()
|
|
{
|
|
return $this->belongsTo(Tenant::class);
|
|
}
|
|
|
|
public function confirmedBy()
|
|
{
|
|
return $this->belongsTo(User::class, 'confirmed_by');
|
|
}
|
|
|
|
public function createdBy()
|
|
{
|
|
return $this->belongsTo(User::class, 'created_by');
|
|
}
|
|
|
|
public function getPeriodNameAttribute()
|
|
{
|
|
$persianMonths = [
|
|
1 => 'فروردین', 2 => 'اردیبهشت', 3 => 'خرداد',
|
|
4 => 'تیر', 5 => 'مرداد', 6 => 'شهریور',
|
|
7 => 'مهر', 8 => 'آبان', 9 => 'آذر',
|
|
10 => 'دی', 11 => 'بهمن', 12 => 'اسفند'
|
|
];
|
|
return ($persianMonths[$this->month] ?? $this->month) . ' ' . $this->year;
|
|
}
|
|
}
|