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