- 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
23 lines
399 B
PHP
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);
|
|
}
|
|
}
|