vernova/app/Models/EmployeeSettlement.php
2026-07-26 19:58:27 +03:30

71 lines
1.6 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class EmployeeSettlement extends Model
{
use HasFactory;
protected $fillable = [
'tenant_id',
'employee_id',
'settlement_type',
'settlement_date',
'last_working_date',
'total_payable',
'total_deductions',
'net_payable',
'currency_id',
'notes',
'processed_by',
'processed_at',
];
protected $casts = [
'settlement_date' => 'date',
'last_working_date' => 'date',
'processed_at' => 'datetime',
'total_payable' => 'decimal:0',
'total_deductions' => 'decimal:0',
'net_payable' => 'decimal:0',
];
public function tenant()
{
return $this->belongsTo(Tenant::class);
}
public function employee()
{
return $this->belongsTo(Employee::class);
}
public function currency()
{
return $this->belongsTo(Currency::class);
}
public function processedBy()
{
return $this->belongsTo(User::class, 'processed_by');
}
public function financials()
{
return $this->hasMany(EmployeeFinancial::class, 'settlement_id');
}
public function getSettlementTypeLabelAttribute()
{
return match($this->settlement_type) {
'resignation' => 'استعفا',
'termination' => 'اخراج',
'end_of_contract' => 'پایان قرارداد',
default => $this->settlement_type,
};
}
}