• 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

enroll_table three field fetch to payment form to create payment field in laravel 5.5

Laravel Delete and Update

ConstraintViolationListInterface to Exception in Symfony

Natural ORDER in Laravel Eloquent ORM

display WooCommerce “Add to cart” button with short-code [add_to_cart ] dynamically

Laravel Gates using model and returns "Using $this when not in object context" Line 28 of AzureUser model

How to get Laravel's CSRF Token from Another Website?

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

How do I enable error reporting in Laravel?

Prevent blank space in pdf pages (DomPdf)

Normalize DateInterval in PHP

XAMPP keeps showing Dashboard/Welcome Page instead of the Configuration Page

laravel sanctum Route [login] not defined

Dropdown with current value from Mysql

Reorder attribute dropdown terms in Woocommerce single variable products

About Contact Privacy policy Terms and conditions