Files
opensem/app/Console/Commands/untranslateShelves.php
2022-03-21 21:52:12 +01:00

51 lines
1.1 KiB
PHP

<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Models\Shop\Category;
class untranslateShelves extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'untranslateShelves';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Migrations of shelves';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$categories = Category::all();
foreach ($categories as $category) {
$trans = json_decode($category->name, true);
$name = $trans['fr'];
$trans = $category->description ? json_decode($category->description, true) : false;
$description = $trans ? $trans['fr'] : '';
$category->update(['name' => $name, 'description' => $description]);
}
}
}