• 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

Appending data to an anchor tag

Laravel Collections. Is there some kind of assertStructure method?

How to convert the int value to inch in PHP [closed]

Laravel Delete and Update

Handling expired token in Laravel

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

Cannot pass null argument when using type hinting

Saving Data from form to database using AngularJS and php

Why do I have invalid argument supply for foreach in Laravel for json response? [duplicate]

Why getting "Build step 'Execute shell' marked build as failure" error while creating a backup tar for files

how to search for a file with php

How can I make Laravel return a custom error for a JSON REST API

Debugging Stripe Webhook Event

Filter array by skipping every nth element from the end

Google API Heatmap Layer exception, why?

About Contact Privacy policy Terms and conditions