feat: add automated monthly payroll generation and update unpaid previous month records

This commit is contained in:
Yoga Pangestu 2026-04-30 14:03:51 +07:00
parent 7fbf5dc6c2
commit fb1ad29741
2 changed files with 11 additions and 0 deletions

View File

@ -42,6 +42,14 @@ public function handle()
try {
DB::transaction(function () use ($users, $periodMonth, &$count) {
$previousMonth = Carbon::parse($periodMonth)->subMonth()->format('Y-m');
Payroll::where('period_month', $previousMonth)
->where('is_paid', false)
->update([
'is_paid' => true,
'paid_at' => Carbon::now(),
]);
foreach ($users as $user) {
$exists = Payroll::where('user_id', $user->id)
->where('period_month', $periodMonth)

View File

@ -2,7 +2,10 @@
use Illuminate\Foundation\Inspiring;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Schedule;
Artisan::command('inspire', function () {
$this->comment(Inspiring::quote());
})->purpose('Display an inspiring quote');
Schedule::command('payroll:generate')->monthlyOn(1, '00:00');