mirror of https://github.com/kcal-app/kcal.git
Convert existing name columns to lowercase
This commit is contained in:
parent
afe2bdafe0
commit
38db1ce41d
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue