Convert existing name columns to lowercase

This commit is contained in:
Christopher C. Wells 2021-01-18 08:43:31 -08:00
parent afe2bdafe0
commit 38db1ce41d
1 changed files with 27 additions and 0 deletions

View File

@ -0,0 +1,27 @@
<?php
use App\Models\Food;
use App\Models\Recipe;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Str;
class ConvertNamesLowercase extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
foreach (Recipe::all() as $recipe) {
$recipe->name = Str::lower($recipe->name);
$recipe->save();
}
foreach (Food::all() as $recipe) {
$recipe->name = Str::lower($recipe->name);
$recipe->save();
}
}
}