• 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

Add bold text and line break into Laravel Notification Email

HTML + PHP + PHPMAILER

Class AppHttpControllersUserController Does Not Exist

Issue saving card for customer

Laravel Factory not calling callback 'afterCreating'

How to override htaccees file for cache control header

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

PHPUnit 7: Failed asserting that exception of type InvalidArgumentException is thrown

Laravel post contact form giving me error 419

Getting public posts of a random user from Facebook API

How to put php code inside opening and closing shortcodes

Laravel views are showing from cache on one server but works fine on other server

MySQL order by field in Eloquent

Hide specific products from unlogged users based in product category in WooCommerce

dockerizing Laravel + vue

About Contact Privacy policy Terms and conditions