31 lines
650 B
PHP
31 lines
650 B
PHP
<?php
|
|
|
|
namespace App\Services;
|
|
|
|
use App\Models\ClientInvoice;
|
|
|
|
class ClientInvoiceApprovalService
|
|
{
|
|
public function approve(ClientInvoice $invoice): ClientInvoice
|
|
{
|
|
if ($invoice->approved_at === null) {
|
|
$invoice->forceFill([
|
|
'approved_at' => now(),
|
|
])->save();
|
|
}
|
|
|
|
return $invoice->refresh();
|
|
}
|
|
|
|
public function requireApproval(ClientInvoice $invoice): ClientInvoice
|
|
{
|
|
if ($invoice->approved_at !== null) {
|
|
$invoice->forceFill([
|
|
'approved_at' => null,
|
|
])->save();
|
|
}
|
|
|
|
return $invoice->refresh();
|
|
}
|
|
}
|