Using Artisan call to pass non-option arguments

0 votes

In the shell I can create a database migration (for example) like so:

./artisan migrate:make --table="mytable" mymigration

Using Artisan::call() I can't work out how to pass a non-argument parameter ("mymigration" in this example). I have tried many variants of the code below:

Artisan::call('db:migrate', ['--table' => 'mytable', 'mymigration'])

Anyone got any ideas? I have been using shell_exec('./artisan ...') in the meantime but I'm not happy with the approach.

Sep 28, 2020 in Laravel by kartik
• 37,530 points
544 views

1 answer to this question.

0 votes

Hello @kartik,

Use:

Artisan::call('db:migrate', ['' => 'mymigration', '--table' => 'mytable']) 

should work.

Incidentally db:migrate isn't an artisan command out of the box. 

Hope it helps!!
Thank you!!

answered Sep 28, 2020 by Niroj
• 82,820 points

Related Questions In Laravel

0 votes
1 answer

How to make a new page with routing using Laravel?

Hey @kartik, First you have to go to ...READ MORE

answered Mar 18, 2020 in Laravel by Niroj
• 82,820 points
3,018 views
+1 vote
1 answer

How to make anchor tag with routing using Laravel?

Hey @kartik, First you have to go to ...READ MORE

answered Mar 18, 2020 in Laravel by Niroj
• 82,820 points
9,976 views
0 votes
1 answer

How to pass URL param in Laravel?

Hello, First you have to go to routes ...READ MORE

answered Mar 18, 2020 in Laravel by Niroj
• 82,820 points
3,435 views
0 votes
1 answer

How to pass data with routing ?

First you can follow how to pass ...READ MORE

answered Mar 18, 2020 in Laravel by Niroj
• 82,820 points
200 views
0 votes
1 answer

Uncaught Error: Bootstrap's JavaScript requires jQuery

Hello @kartik, You have provided wrong order for ...READ MORE

answered Apr 28, 2020 in JQuery by Niroj
• 82,820 points
11,597 views
0 votes
1 answer

How to make Bootstrap popover Appear/Disappear on hover instead of click?

Hello @kartik, Set the trigger option of the popover to hover instead ...READ MORE

answered May 12, 2020 in JQuery by Niroj
• 82,820 points
744 views
0 votes
1 answer

How to enable Bootstrap tooltip on disabled button?

Hii @kartik, You can wrap the disabled button ...READ MORE

answered May 12, 2020 in JQuery by Niroj
• 82,820 points
2,286 views
+1 vote
2 answers

How to set cache false for getJSON in jQuery?

You can't pass any configuration parameters to ...READ MORE

answered Oct 7, 2020 in JQuery by Amit
• 140 points
810 views
0 votes
2 answers

How to pass variable to next page using php?

Simply use Sessions my friend Page1: session_start(); $ ...READ MORE

answered Oct 6, 2020 in Laravel by anonymous
• 140 points
324 views
0 votes
1 answer

How to get response from Artisan call?

Hello @kartik,  You can simply use: Artisan::output() READ MORE

answered Dec 2, 2020 in Laravel by Niroj
• 82,820 points
208 views