• 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

PHP: remove filename from path

could not find driver Debian SQL Server PHP

PHP date() with timezone?

Yoast SEO (WordPress Plugin) - Get plugin generated data manually

PHP web3 ERC20 token function call

How to add a sidebar to Woocommerce Shop Page?

Unable to create lockable file - Laravel 8 & PHP 8

Laravel You requested 1 items, but there are only 0 items available

Coinpayments create_transaction "ERROR: Invalid command!"

Fatal error: Array callback has to contain indices 0 and 1

Check if my GET request has Header: Token

how to loop through json response data using ajax jquery?

How can I easily switch between PHP versions on Mac OSX?

Custom Button next to “ADD TO CART” button of WooCommerce based on Product Type

Hi, I am making a contact form thingy, and my php isn't working any reason why?

About Contact Privacy policy Terms and conditions