forked from eatvio/eatvio-infra
refactoring: folowing phpinsights recomendations
This commit is contained in:
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use App\Models\Recipe;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class UpdateSlugs extends Command
|
||||
{
|
||||
@@ -27,19 +27,18 @@ class UpdateSlugs extends Command
|
||||
public function handle()
|
||||
{
|
||||
Recipe::where('slug', '')
|
||||
->get()
|
||||
->each(
|
||||
function ($model) {
|
||||
$newName = $model->title . " 2612";
|
||||
$oldName = Str::replaceLast(' 2612', '', $newName);
|
||||
->get()
|
||||
->each(
|
||||
function ($model) {
|
||||
$newName = $model->title . ' 2612';
|
||||
$oldName = Str::replaceLast(' 2612', '', $newName);
|
||||
|
||||
$model->title = $newName;
|
||||
$model->save();
|
||||
$model->title = $newName;
|
||||
$model->save();
|
||||
|
||||
$model->title = $oldName;
|
||||
$model->save();
|
||||
}
|
||||
);
|
||||
//
|
||||
$model->title = $oldName;
|
||||
$model->save();
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user