dstpabuaran.com/app/Models/PayrollAdjustment.php
Yoga Pangestu 6dbe9da581 feat: add payroll management features including payroll periods, adjustments, and payment processing
- Implemented routes for managing payroll periods, including current, close, and reopen functionalities.
- Added payroll payment and cancellation routes.
- Introduced payroll adjustments with store and delete functionalities.
- Created comprehensive feature tests for payroll management, covering authentication, CRUD operations, and business logic.
- Ensured proper handling of payroll adjustments and their impact on payroll totals.
- Developed tests for generating payrolls and managing payroll periods, ensuring accurate status transitions and data integrity.
2026-07-30 17:06:52 +07:00

54 lines
1.3 KiB
PHP

<?php
namespace App\Models;
use App\Enums\PayrollAdjustmentType;
use Illuminate\Database\Eloquent\Attributes\Guarded;
use Illuminate\Database\Eloquent\Attributes\Scope;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
#[Guarded(['id'])]
class PayrollAdjustment extends Model
{
use HasFactory, SoftDeletes;
protected function casts(): array
{
return [
'type' => PayrollAdjustmentType::class,
'amount' => 'integer',
];
}
#[Scope]
protected function bonus(Builder $query): void
{
$query->where('type', PayrollAdjustmentType::BONUS);
}
#[Scope]
protected function deduction(Builder $query): void
{
$query->where('type', PayrollAdjustmentType::DEDUCTION);
}
public function attendance(): BelongsTo
{
return $this->belongsTo(Attendance::class);
}
public function createdBy(): BelongsTo
{
return $this->belongsTo(User::class, 'created_by_id');
}
public function payroll(): BelongsTo
{
return $this->belongsTo(Payroll::class);
}
}