• 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 to sort by a custom appended relation to model

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

How to pass data to all views in Laravel 5?

sort() not affecting original array while inside foreach loop

Laravel dosen't connect with Oracle

renameColumn migration fails for existing column with columns does not exist error

If you intend you use SMTP, add your SMTP Code after this Line

Laravel 5 issue with wherePivot

How to read laravel_session cookies saved in cookie memory of browser in client side?

how to remove white space in select 2

args[max_input] woocommerce if statement confused

Laravel 4 Redirect::back() not going to previous page (refreshing current page)

Saving Data from form to database using AngularJS and php

Add 2 Webcam in one page with WebcamJS

How to fix bootstrap multiselect search data using ajax

About Contact Privacy policy Terms and conditions