3
Today I call a command
for controler
perfectly, but I would like to send variables as well. In controller
, call the command
that way:
\Artisan::call('syncustomer:sav');
The name attribute of the current command:
protected $name = 'syncustomer:sav';
In the documentation I saw that I could pass the variables in the following way:
\Artisan::call('syncustomer:sav', ['[email protected]']);
Thus the name
of command
would look like this:
protected $name = 'syncustomer:sav {data}';
The controller
does not show error, but when I try to catch this variable in handle()
gives error saying that there is no argument data
:
public function handle(){
$email = $this->argument('data');
DB::table('customer')
->where('email', '[email protected]')
->update(array('email' => $email));
}
The data argument does not exist
.
Can someone help me?
Already tried using associtative array?
['data' => '[email protected]']
– JuniorNunes
Yes, it gives the same problem
– Isaias Lima
That’s strange, because in doc he’s doing like this: https://laravel.com/docs/5.3/artisan#programmatically-executing-Commands
– JuniorNunes
I figured out how to do it, I’ll put it in answer
– Isaias Lima