Initial Commit
This commit is contained in:
commit
ddf09fe00c
113 changed files with 187148 additions and 0 deletions
52
app/Console/Commands/CardExport.php
Normal file
52
app/Console/Commands/CardExport.php
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
use App\Models\Character;
|
||||
use App\Models\Raid;
|
||||
use App\Models\Card;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class CardExport extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'card:export';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Export card data';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$data = collect();
|
||||
foreach(Card::with(['character', 'raid'])->get() as $card) {
|
||||
|
||||
$row = collect([
|
||||
'message' => $card->body,
|
||||
'character' => $card->character ? $card->character->name : null,
|
||||
'raid' => $card->raid ? $card->raid->name : null,
|
||||
'class' => $card->class,
|
||||
'role' => $card->role
|
||||
])->filter()->toArray();
|
||||
|
||||
$data->push($row);
|
||||
}
|
||||
|
||||
$this->line($data->toJson(JSON_PRETTY_PRINT));
|
||||
}
|
||||
}
|
||||
Reference in a new issue