• 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

Uploading video to Youtube using Youtube Data API V3 and Google API Client PHP -- getting 401 (unauthorized) message

Error converting docx to pdf using Unoconv

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

Trying to mock an http client that is inside a controller, using phpunit, but it doesn't work

What is my SQL missing?

How to run or debug php on Visual Studio Code (VSCode)

Custom add to cart button URL for specific product in WooCommerce?

Correct way to use LIKE '%{$var}%' with prepared statements?

Insert multidimensional array to codeigniter cart

Return new collection without modifying original collection

is there any way to validate a field that sometime is File(image) && sometime is String(Src of same image)

Populate Dynamic Dropdowns List in Codeigniter

Reload parent page after submit in iframe

Refresh specific HTML content that retrieves data from MySQL

Inserting Country Selection into MySQL PHP [duplicate]

About Contact Privacy policy Terms and conditions