Files
MKM/app/Observers/ClientObserver.php
Jp 8c6fa6cb08 refactor(client): extract base account generation to command
Move the logic for generating base accounts for a new client from the ClientObserver into a dedicated command class (GenerateBaseAccountCommand). This improves code organization and reusability.

- The command is now used in the ClientObserver::created method.
- The command is also made available as a manual action in the AccountsRelationManager table header, allowing admins to generate base accounts for existing clients that lack them.
- Added necessary imports to the CreateSale page, though the command is not directly used there in this diff, suggesting preparatory work for future integration.
2026-02-16 02:02:26 +08:00

51 lines
897 B
PHP

<?php
namespace App\Observers;
use App\Commands\Clients\GenerateBaseAccountCommand;
use App\Models\Client;
use Illuminate\Support\Facades\DB;
class ClientObserver
{
/**
* Handle the Client "created" event.
*/
public function created(Client $client): void
{
app(GenerateBaseAccountCommand::class)->execute($client);
}
/**
* 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
{
//
}
}