Last active
August 29, 2015 14:02
-
-
Save thewinterwind/bf21c4e30d6a9d09cb47 to your computer and use it in GitHub Desktop.
Artisan Files for Streak Counting Tutorial (2 files combined here)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// this is /app/start/artisan.php | |
<?php | |
/* | |
|-------------------------------------------------------------------------- | |
| Register The Artisan Commands | |
|-------------------------------------------------------------------------- | |
| | |
| Each available Artisan command must be registered with the console so | |
| that it is available to be called. We'll register every command so | |
| the console gets access to each of the command object instances. | |
| | |
*/ | |
Artisan::add(new UpdateStreaks); | |
// this is /app/commands/UpdateStreaks.php | |
<?php | |
use Illuminate\Console\Command; | |
use Symfony\Component\Console\Input\InputOption; | |
use Symfony\Component\Console\Input\InputArgument; | |
class UpdateStreaks extends Command { | |
/** | |
* The console command name. | |
* | |
* @var string | |
*/ | |
protected $name = 'ss:update-streaks'; | |
/** | |
* The console command description. | |
* | |
* @var string | |
*/ | |
protected $description = 'Update the stock streaks'; | |
/** | |
* Create a new command instance. | |
* | |
* @return void | |
*/ | |
public function __construct() | |
{ | |
parent::__construct(); | |
} | |
/** | |
* Execute the console command. | |
* | |
* @return mixed | |
*/ | |
public function fire() | |
{ | |
(new StoringController)->store_streaks(); | |
} | |
/** | |
* Get the console command arguments. | |
* | |
* @return array | |
*/ | |
protected function getArguments() | |
{ | |
return array( | |
array('example', InputArgument::OPTIONAL, 'An example argument.'), | |
); | |
} | |
/** | |
* Get the console command options. | |
* | |
* @return array | |
*/ | |
protected function getOptions() | |
{ | |
return array( | |
array('example', null, InputOption::VALUE_OPTIONAL, 'An example option.', null), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment