some time-consuming third-party requests are encountered in the current project, so I want to write a command to execute these time-consuming third-party requests asynchronously. The command, is triggered when the user requests the relevant interface and the command is executed asynchronously. At this point, users do not have to wait for the results of command, they can continue to browse.
Code:
public function sync(){
$enterId = $this->request->input("enter_id");
$warehouseId = $this->request->input("warehouse_id");
$personId = $this->request->attributes->get("person")->id;
$warehouse = Warehouse::getById($warehouseId, $enterId);
$warehouse->syncValid(); //
$commandKey = ["key" => "SYNC_FBA","enterprise" => $enterId, "warehouse"=>$warehouseId];
$commandId = CommandLog::getCommand($enterId, $personId, $commandKey);
Artisan::call("sync:fba",[
"enterprise"=> $enterId,
"--warehouse"=> $warehouseId,
"--command"=> $commandId,
"--help"=>true
]); //FBA
return $this->response(["data"=>["command_id"=>$commandId]]);
}
I would like to ask you guys how you can execute the sync:fba command asynchronously