using the event listening function of laravel for the first time, if you want to implement the following business logic, please tell me how to write reasonable code!
//controller codes
class OrderController extends Controller
{
function create()
{
//do something ...
event(new OrderWasCreated($order_id));
}
}
//api codes
class ApiController extends Controller
{
function sendEmail()
{
//do something ...
}
}
//Listeners codes
class SendEmail
{
public function handle(OrderWasCreated $event)
{
//send email ...
}
}
like the above three pieces of code, now I want to implement the business logic of sending mail in the listener when the order is created, but I"m not sure where to write the code to handle the mail. So I created an api to deal with, how should it be associated with the listener?