47 lines
798 B
PHP
47 lines
798 B
PHP
<?php
|
|
|
|
namespace App\Commands;
|
|
|
|
use LaravelZero\Framework\Commands\Command;
|
|
use Log;
|
|
use App\Models\Game;
|
|
use App\Wikipage;
|
|
|
|
class Wiki extends Command
|
|
{
|
|
/**
|
|
* The signature of the command.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $signature = 'wiki {id}';
|
|
|
|
/**
|
|
* The description of the command.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $description = 'Make a Mediawiki article about a game #ID';
|
|
|
|
/**
|
|
* Execute the console command.
|
|
*
|
|
* @return mixed
|
|
*/
|
|
public function handle()
|
|
{
|
|
$id = $this->argument('id');
|
|
if (!is_numeric($id)) {
|
|
Log::error('ID should be numeric.');
|
|
return;
|
|
}
|
|
$game = Game::where('id', $id)->first();
|
|
if (!isset($game)) {
|
|
Log::error('Game not found.');
|
|
return;
|
|
}
|
|
$page = new Wikipage($game);
|
|
$page->create();
|
|
}
|
|
}
|