• 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

Jquery DataTables: Data not displaying in table via Ajax

PHP | "The requested PHP extension bcmath is missing from your system."

Laravel Blade checkbox not checked

I can't delete my image when it is liked because of the foreign key in mysql

PHPUnit (Phar) Fatal Error Only When Test Fails

Why the name of trucks are same in 2nd and 3rd record of company data retrieval?

SendGrid: Sending an email to multiple recipients without other emails being shown on the "to" field

Multiple order by in WooCommerce

Dynamic table in HTML using MySQL and php

How can I make a full text index of the column?

With doctrine ODM, can I embed many subdocuments in a main document?

Star and Half Star Rating in Laravel

PHP code for generating decent-looking coupon codes (mix of letters and numbers)

XML to CSV with PHP converter [problem with images grabing]

How can I create a Download Page with post php method?

About Contact Privacy policy Terms and conditions