insert and insertgetid laravel code example
Example 1: insertgetid laravel 8
/**
* The attributes that are mass assignable.
*
* @var array
*/
public function index()
{
$id = User::insertGetId(
['email' => '[email protected]','name' => 'john']
);
}
Example 2: insertgetid laravel 8
/**
* The attributes that are mass assignable.
*
* @var array
*/
public function index()
{
$id = DB::table('users')->insertGetId(
['email' => '[email protected]','name' => 'john']
);
}