seteo de timestamps al insertar
This commit is contained in:
parent
5ea06ff003
commit
09a024b69d
|
@ -6,6 +6,8 @@
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||||
use Illuminate\Database\Seeder;
|
use Illuminate\Database\Seeder;
|
||||||
|
use App\Models\Region;
|
||||||
|
use App\Models\Barrio;
|
||||||
|
|
||||||
class BarrioSeeder extends Seeder
|
class BarrioSeeder extends Seeder
|
||||||
{
|
{
|
||||||
|
@ -14,14 +16,12 @@ class BarrioSeeder extends Seeder
|
||||||
*/
|
*/
|
||||||
public function run(): void
|
public function run(): void
|
||||||
{
|
{
|
||||||
DB::table('regiones')->insert([
|
$prueba_id = Region::create([
|
||||||
['name'=>'PRUEBA', 'created_at'=>Date::now()]
|
'name' => 'PRUEBA',
|
||||||
]);
|
])->id;
|
||||||
|
|
||||||
$prueba_id = DB::table('regiones')->where('name','PRUEBA')->first()->id;
|
Barrio::create([
|
||||||
|
'name'=>'PRUEBA','region_id'=>$prueba_id, 'created_at'=>Date::now()
|
||||||
DB::table('barrios')->insert([
|
|
||||||
['name'=>'PRUEBA','region_id'=>$prueba_id, 'created_at'=>Date::now()],
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||||
use Illuminate\Database\Seeder;
|
use Illuminate\Database\Seeder;
|
||||||
|
use Illuminate\Support\Facades\Date;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Support\Arr;
|
use Illuminate\Support\Arr;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
@ -47,7 +48,9 @@ public function run(): void
|
||||||
'price' => $record[$precioColumn],
|
'price' => $record[$precioColumn],
|
||||||
'solidario' => $parsed['solidario'],
|
'solidario' => $parsed['solidario'],
|
||||||
'bono' => $tipo == 'B',
|
'bono' => $tipo == 'B',
|
||||||
'categoria_id' => $currentCategoria->id
|
'categoria_id' => $currentCategoria->id,
|
||||||
|
'created_at' => Date::now(),
|
||||||
|
'updated_at' => Date::now(),
|
||||||
];
|
];
|
||||||
|
|
||||||
$caracteristicasToInsert[] = [
|
$caracteristicasToInsert[] = [
|
||||||
|
|
|
@ -15,10 +15,10 @@ class CaracteristicaSeeder extends Seeder
|
||||||
public function run(): void
|
public function run(): void
|
||||||
{
|
{
|
||||||
DB::table('caracteristicas')->insert([
|
DB::table('caracteristicas')->insert([
|
||||||
['name' => 'SIN GLUTEN', 'key' => 'S-G', 'created_at' => Date::now()],
|
['name' => 'SIN GLUTEN', 'key' => 'S-G', 'created_at' => Date::now(), 'updated_at' => Date::now()],
|
||||||
['name' => 'SIN SAL AGREGADA', 'key' => 'S-S', 'created_at' => Date::now()],
|
['name' => 'SIN SAL AGREGADA', 'key' => 'S-S', 'created_at' => Date::now(), 'updated_at' => Date::now()],
|
||||||
['name' => 'SIN AZÚCAR AGREGADA', 'key' => 'S-A', 'created_at' => Date::now()],
|
['name' => 'SIN AZÚCAR AGREGADA', 'key' => 'S-A', 'created_at' => Date::now(), 'updated_at' => Date::now()],
|
||||||
['name' => 'SIN PRODUCTOS DE ORIGEN ANIMAL', 'key' => 'S-P-A', 'created_at' => Date::now()],
|
['name' => 'SIN PRODUCTOS DE ORIGEN ANIMAL', 'key' => 'S-P-A', 'created_at' => Date::now(), 'updated_at' => Date::now()],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue