52 lines
1.1 KiB
PHP
52 lines
1.1 KiB
PHP
<?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));
|
|
}
|
|
}
|