29.07.2016 Views

laravel-5

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Artisan Console 167<br />

.<br />

1 /**<br />

2 * The name and signature of the console command.<br />

3 *<br />

4 * @var string<br />

5 */<br />

6 protected $signature = 'email:send<br />

7 {user : The ID of the user}<br />

8 {--queue= : Whether the job should be queued}';<br />

Retrieving Input<br />

While your command is executing, you will obviously need to access the values for the arguments<br />

and options accepted by your command. To do so, you may use the argument and option methods:<br />

To retrieve the value of an argument, use the argument method:<br />

.<br />

1 /**<br />

2 * Execute the console command.<br />

3 *<br />

4 * @return mixed<br />

5 */<br />

6 public function handle()<br />

7 {<br />

8 $userId = $this->argument('user');<br />

9<br />

10 //<br />

11 }<br />

If you need to retrieve all of the arguments as an array, call the argument with no parameters:<br />

.<br />

1 $arguments = $this->argument();<br />

Options may be retrieved just as easily as arguments using the option method. Like the argument<br />

method, you may call option without any arguments in order to retrieve all of the options as an<br />

array:

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!