31 lines
707 B
PHP
31 lines
707 B
PHP
<?php
|
|
|
|
namespace App\Services;
|
|
|
|
use App\Models\DetailPayment;
|
|
use Illuminate\Support\Carbon;
|
|
|
|
class CekDenda
|
|
{
|
|
public function cekDenda()
|
|
{
|
|
$prevMonth = Carbon::now()->subMonth()->month;
|
|
$prevYear = Carbon::now()->subMonth()->year;
|
|
$now = Carbon::now()->day;
|
|
|
|
if ($now >= 10) {
|
|
$arrears = DetailPayment::where('status', 'unpaid')
|
|
->where('payment_month', $prevMonth)
|
|
->where('payment_year', $prevYear)->get();
|
|
|
|
foreach ($arrears as $arrear) {
|
|
$arrear->update([
|
|
'penalty' => 20000
|
|
]);
|
|
}
|
|
}
|
|
|
|
return ['message' => 'Berhasil'];
|
|
}
|
|
}
|