Files
MKM/app/Observers/ClientObserver.php
2024-08-11 20:03:49 +08:00

88 lines
2.1 KiB
PHP

<?php
namespace App\Observers;
use App\Models\Client;
use Illuminate\Support\Facades\DB;
class ClientObserver
{
/**
* Handle the Client "created" event.
*/
public function created(Client $client): void
{
DB::transaction(function () use ($client) {
$client->accounts()->createMany([
[
'account_type_id' => 1,
'account' => 'Cash',
'normal_balance' => 'debit',
],
[
'account_type_id' => 1,
'account' => 'Input Tax',
'normal_balance' => 'debit',
],
[
'account_type_id' => 1,
'account' => 'Creditable Withholding Tax',
'normal_balance' => 'debit',
],
[
'account_type_id' => 2,
'account' => 'Output Tax',
'normal_balance' => 'credit',
],
[
'account_type_id' => 2,
'account' => 'Payable Withholding Tax',
'normal_balance' => 'credit',
],
[
'account_type_id' => 5,
'account' => 'Vat Exempt Revenue',
'normal_balance' => 'credit',
],
[
'account_type_id' => 4,
'account' => 'Sales Discount',
'normal_balance' => 'debit',
],
]);
});
}
/**
* Handle the Client "updated" event.
*/
public function updated(Client $client): void
{
//
}
/**
* Handle the Client "deleted" event.
*/
public function deleted(Client $client): void
{
//
}
/**
* Handle the Client "restored" event.
*/
public function restored(Client $client): void
{
//
}
/**
* Handle the Client "force deleted" event.
*/
public function forceDeleted(Client $client): void
{
//
}
}