• 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

SendGrid: Sending an email to multiple recipients without other emails being shown on the "to" field

Normalize DateInterval in PHP

How to skip cart page on woocomerce for certain products only?

Laravel implode array items to new lines

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

how to display a view on laravel 8 and not have a 404 NOT FOUND page?

Access relation of pivot table in Laravel

oauth-private.key does not exist or is not readable

How to redirect to another page and call a Function there on Angular ng-click

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

Why does array_map() with null as callback create an "array of arrays"?

PHP if in_array() how to get the key as well?

How to get an Array value inside an object in an array Php [duplicate]

Utf8 encoding issue with Laravel

Cannot pass null argument when using type hinting

About Contact Privacy policy Terms and conditions