Te recomendamos que revises esta solución en un entorno controlado antes de pasarlo a producción, un saludo.
Ejemplo 1: cómo insertar varias filas en mysql usando laravel
/*
It is really easy to do a bulk insert in Laravel with or without the query builder.
You can use the following official approach.
*/
Entity::upsert([['name'=>'Pierre Yem Mback','city'=>'Eseka','salary'=>10000000],['name'=>'Dial rock 360','city'=>'Yaounde','salary'=>20000000],['name'=>'Ndibou La Menace','city'=>'Dakar','salary'=>40000000]],['name','city'],['salary']);
Ejemplo 2: inserte datos en dos tablas use laravelonce
class Something extends Eloquent
protected $table='something';publicfunction users()
return $this->hasMany('User','id_something');
class User extends Eloquent implements UserInterface, RemindableInterface
use UserTrait, RemindableTrait;
protected $table='something_users';
protected $hidden = array('password','remember_token');publicfunction something()
return $this->belongsTo('Something','id_something');
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)