[WIP] Admin for Families, Genres and Species

This commit is contained in:
Ludovic CANDELLIER
2020-04-13 01:43:04 +02:00
parent 134e04d197
commit b7edcd402f
37 changed files with 655 additions and 334 deletions

View File

@@ -0,0 +1,61 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Models\Shop\Family;
use App\Models\Shop\Genre;
class migrate extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'create_relation';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Migration from old version';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$genres = Genre::all();
foreach ($genres as $genre) {
$family_name = $genre->family;
dump($family_name);
if (!empty($family_name)) {
$family = Family::byName($family_name)->first();
if (isset($family->name))
{
dump($family->name);
$genre->family_id = $family->id;
$genre->save();
} else {
dump("non trouvé");
}
} else {
dump("Aucune famille");
}
}
}
}