• 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 can I solve "laravel/horizon v1.1.0 requires ext-pcntl * -> the requested PHP extension pcntl is missing from your system"?

Display Link Title Instead of URL in XSL

Laravel Unknown Column 'updated_at'

Correct way to use LIKE '%{$var}%' with prepared statements?

Split a string array into pieces

Return multiple values from a function using mysqli_fetch_assoc [closed]

PHPUnit gives error: Target [IlluminateContractsViewFactory] is not instantiable

What is the difference between client-side and server-side programming?

Querying only one row from a one to many relationship laravel

SilverStripe unable to populate multiple member Childs

how to redirect the user back to desired URL after login page in PHP?

Trying to mock an http client that is inside a controller, using phpunit, but it doesn't work

Laravel database insert with combining array and string

How to get total pages of PDF with FPDF?

WordPress + Nginx on non-standard port behind AWS ELB results in broken links

About Contact Privacy policy Terms and conditions