• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

Eloquent insert id with sequence next value

phplaravellaravel-5.3


PHP Snippet 1:

$billing->id = DB::getPdo()->lastInsertId(); // + 1 ?

PHP Snippet 2:

$nextval=DB::select(DB::raw("SELECT nextval('".(new Billing())->getTable()."_id_seq') as seq"))[0]->seq;

$billing = new Billing;

$billing->id = $nextval;
$billing->companyname = $request->companyname;
// ...

$billing->save();

Related Snippets

Form repeater send wrong data with last element in Laravel

How can I stop a symfony process which is listening on http://127.0.0.1:8000

Make survey at laravel 5.4 and MySQL

Custom post type single page not working

Add and update products to session cart in Laravel

Exact alternate to mcrypt_encrypt in PHP 7.2

How can I make a full text index of the column?

Laravel set default language not working

How can I pass the list to the component variable in Laravel?

Creating command to backup MySql database in Laravel

Send Outlook 2010 email using PHP

Comma separated list from array with "and" before last element

GuzzleHttp Hangs When Using Localhost

How to Install Composer Require doctrine/dbal

auth pages not getting css in laravel

About Contact Privacy policy Terms and conditions