Files
opensem/app/Console/Commands/untranslateShelves.php
2024-01-05 01:30:46 +01:00

31 lines
790 B
PHP

<?php
namespace App\Console\Commands;
use App\Models\Shop\Category;
use Illuminate\Console\Command;
class UntranslateShelves extends Command
{
protected $signature = 'untranslateShelves';
protected $description = 'Migrations of shelves';
public function __construct()
{
parent::__construct();
}
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]);
}
}
}