samedi 18 mai 2019

Laravel 5.6 - How to run job or event with parameters from command line?

I have an App\Jobs\BanUser job which accepts a parameter id to block a bad user by passing their id. That works perfectly if called from a controller like this:

dispatch(new BanUser($id));

But when I try to do that from the tinker command line with the full namespace like this:

dispatch(new App\Jobs\BanUser('1'));

I get this error:

PHP Fatal error: Class 'App/Jobs/BanUser' not found in Psy Shell code on line 1

Any idea how to accomplish this job with the passed id parameter from the command line?

NOTE: If the solution requires starting up a queue from command line just for this job, maybe it's best to set it as an event? I don't want it to queue, just want to be able to run it in real time but having the passing parameter and executing the BanUser respective code from command line issue for either job or event.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire