I have controller like this
public function store(Request $request) { Artisan::call("php artisan infyom:scaffold {$request['name']} --fieldsFile=public/Product.json"); }
Show me error
There are no commands defined in the "php artisan infyom" namespace.
When I run this command in CMD it work correctly
So we can do it by using Artisan facade. In Laravel Artisan facade that way we can easily run the all artisan command also with argument. So Artisan facade have two method one call() and another one is queue() through we can simply make process in call like seeder and also migration run etc.
In Laravel, we can run Laravel Development server by typing php artisan serve command on terminal or command line. Make sure your in Laravel's project root directory. If not change your present working directory.
You need to remove php artisan
part and put parameters into an array to make it work:
public function store(Request $request) { Artisan::call("infyom:scaffold", ['name' => $request['name'], '--fieldsFile' => 'public/Product.json']); }
https://laravel.com/docs/5.2/artisan#calling-commands-via-code
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