refactoring: folowing phpinsights recomendations

This commit is contained in:
Anatoliy Poloz
2023-12-28 17:07:09 +03:00
parent 0efb8536dd
commit 9b2d703374
23 changed files with 244 additions and 170 deletions

View File

@@ -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();
}
);
}
}