Files
MKM/app/Actions/Sales/CreateSaleAction.php
Jp e04689acca refactor(sales): replace service with command and action pattern
- Replace SaleService with CreateSaleCommand and CreateSaleAction for better separation of concerns
- Move sale creation logic into dedicated command class following command pattern
- Update CreateSale.php to use new action instead of direct service call
- Wrap sale creation in database transaction for data consistency
2026-02-16 01:22:00 +08:00

23 lines
399 B
PHP

<?php
namespace App\Actions\Sales;
use App\Commands\Sales\CreateSaleCommand;
use App\Models\Sale;
class CreateSaleAction
{
/**
* Create a new class instance.
*/
public function __construct(private CreateSaleCommand $createSaleCommand)
{
//
}
public function __invoke(array $data): Sale
{
return $this->createSaleCommand->execute($data);
}
}