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 27 in Laravel by kartik
• 30,630 points
39 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 27 by Niroj
• 66,420 points

Related Questions In Laravel

+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 in Laravel by Niroj
• 66,420 points
2,699 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 in Laravel by Niroj
• 66,420 points
1,169 views
0 votes
1 answer

How to pass data with routing ?

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

answered Mar 18 in Laravel by Niroj
• 66,420 points
88 views
0 votes
1 answer

How to pass data through URL and access through controller in Laravel?

Hello, You can  first refer how to  Create controller through ...READ MORE

answered Mar 18 in Laravel by Niroj
• 66,420 points
2,229 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 in JQuery by Niroj
• 66,420 points
3,061 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 in JQuery by Niroj
• 66,420 points
226 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 in JQuery by Niroj
• 66,420 points
803 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 in JQuery by Amit
• 140 points
227 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 in Laravel by anonymous
• 140 points
33 views
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 in Laravel by Niroj
• 66,420 points
214 views