In my route I have
Route::get('artisan/{command}/{param}', 'CacheController@show');
And in my controller i have
public function show($id, $param)
{
$artisan = Artisan::call($id,['flag'=>$param]);
$output = Artisan::output();
return $output;
}
I want to be able to call route:cache and cache:clear by accessing domain.com/artisan/cache/clear or route/cache but when I call them it returned something like this
Command "cache" is not defined.
It only called cache, not cache:clear what possibility going wrong?
Modify your code like this:
$artisan = \Artisan::call($command.":".$param);
$output = \Artisan::output();
return $output;
Flag argument is used to pass the arguments of an artisan command.
You are calling an id when you have called it command
so your function needs to look like this
public function show($command, $param) {
$artisan = Artisan::call($command,['flag'=>$param]);
$output = Artisan::output();
return $output;
}
So your URL can look like this domain.com/artisan/cache/clear which means that you are calling this route
Route::get('artisan/{command}/{param}', 'CacheController@show');
So you need $command intead of $id
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With