• 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

How do I call a php file with axios?

How avoid Moved Permanently The document has moved here

With doctrine ODM, can I embed many subdocuments in a main document?

Input and output values for php into the browser?

Laravel unique validation on multiple columns

How to test laravel controller method?

Edit XML in HTML form and submit to self

protect my blog content

How do I get friend list from Friends table with counts of friends of my friends

Laravel: HTML in notification

Why the name of trucks are same in 2nd and 3rd record of company data retrieval?

Creating a config file in PHP

(Cache::lock()) -> get() -- Under what conditions does it return false?

Laravel print last executed SQL query with Query log

Adding Multiple Custom Post Types in Wordpress

About Contact Privacy policy Terms and conditions