As developers, we often map business processes to digital processes, from sending an email to something quite complex. Mapping Business Process in Laravel 👀
class PlaceOrderController { public function __construct( private readonly FirstOrCreateCustomer $action, ) {} public function __invoke(PlaceOrderRequest $request): RedirectResponse { // Create our customer record. $customer = $this->action->handle([]); dispatch(new PlaceOrder($customer, $request)); Session::put('status', 'Your order is being processed.'); return redirect()->back(); }}
class PlaceOrder implements ShouldQueue { use Dispatchable; use InteractsWithQueue; use Queueable; use SerializesModels; public function _construct( public readonly Customer $customer, public readonly Request $request, ) {} public function handle(): void { // Create an order for our customer.
Using this approach, we can break down our business processes that aren’t digital and make digital representations of them.