• 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

500 (Internal Server Error) with Laravel & Docker [duplicate]

Laravel Sanctum CSRF not authenticating

How do I truncate a decimal in PHP?

How to change 'users' auth table and use another instead Laravel

Laravel SQL query midnight time not showing

How in Laravel run JavaScript code stored in php variable?

PHP Array split string and Integers

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

Laravel multi auth - Authentication user provider [] is not defined

get folder directory from input type file - PHP

Combining a describing and one array with data

Is there a way to use Foundry Model for Authentification inside Functional Tests?

MISSING UPDATES FOR: MEDIA Drupal 9

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

Change the alert text on add to cart action without selected variation in Woocommerce

About Contact Privacy policy Terms and conditions