• 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

PHPMetrics option --excluded-dirs="myfolder" : myfolder dir is not excluded within docker

Transform array, set each array element with parent key php

Composer Curl error 60: SSL certificate problem: unable to get local issuer certificate

Mysqli multi query error

PHP array, move keys and values to new array, but mix it up

error:14094410:SSL routines:ssl3_read_bytes:sslv3 alert handshake failure

MOODLE: What does it mean to aggregate h5p assets?

Xdebug in Laravel is not working with VSCode

auth pages not getting css in laravel

How to validate Envato Purchase Code in PHP

How to to send mail using gmail in Laravel?

Can't find vendor/autoload.php for Ratchet

Exception thrown during the rendering of a template("Parameter "id" for route "url" must match "[^/]++" ("" given) to generate a corresponding URL.")

Why getting "Build step 'Execute shell' marked build as failure" error while creating a backup tar for files

Laravel after login Two factor not working

About Contact Privacy policy Terms and conditions