[WIP] Admin for Families, Genres and Species
This commit is contained in:
61
app/Console/Commands/migrate.php
Normal file
61
app/Console/Commands/migrate.php
Normal 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");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user