Laravel Task: How Can I Pass Params To Use In Method?

- 1 answer

I'm setting up a new Task with Laravel and this task calls to a method from other class, this method needs a parameter.

I have been reading doc from Laravel this says I have to include the param in $signature among {} And I did it.

protected $signature = 'cmd:taskTest {id}';

In my handle function (in command class)

    public function handle()
        WebController::downloadFile(); // downloadFile needs param

And my method, which is called by handle.

public static function downloadFile($warehouseId){
//do something

I have tried writing this in prompt:

php artisan cmd:taskTest 1

It returned an error because it needs the id to find all information in database about this id.

To create the command I ran this:

php artisan make:command


You can retrieve it with the argument method.


For more information: