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

58 lines
1.1 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class EmployeeFinancial extends Model
{
use HasFactory;
protected $fillable = [
'tenant_id',
'employee_id',
'currency_id',
'type',
'amount',
'original_amount',
'description',
'effective_date',
'month',
'year',
'is_paid',
'paid_at',
];
protected $casts = [
'amount' => 'decimal:2',
'original_amount' => 'decimal:2',
'effective_date' => 'date',
'is_paid' => 'boolean',
'paid_at' => 'datetime',
];
public function tenant()
{
return $this->belongsTo(Tenant::class);
}
public function employee()
{
return $this->belongsTo(Employee::class);
}
public function currency()
{
return $this->belongsTo(Currency::class);
}
/**
* Scope: filter by type
*/
public function scopeByType($query, $type)
{
return $query->where('type', $type);
}
}