1
As can be seen in the code below, the field created_at
is the same in all, the only thing that changes is the nome
. Would you have some way of writing the created_at
only once, but insert in all lines?
DB::table('generos')->insert([
[
'nome' => 'Ação',
'created_at' => Carbon::now()->format('Y-m-d H:i:s'),
],
[
'nome' => 'Comédia',
'created_at' => Carbon::now()->format('Y-m-d H:i:s'),
],
[
'nome' => 'Terror',
'created_at' => Carbon::now()->format('Y-m-d H:i:s'),
],
[
'nome' => 'Policial',
'created_at' => Carbon::now()->format('Y-m-d H:i:s'),
],
[
'nome' => 'Fantasia',
'created_at' => Carbon::now()->format('Y-m-d H:i:s'),
]
]);
Have you thought about setting the field in the bank
created_at
asdefault
fornow()
? this way you wouldn’t need to pass any value because thesgbd
will automatically set that field as default tonow
– RFL
I didn’t mind doing that hahaha.
– Diego Vieira