• 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

Laravel Collections. Is there some kind of assertStructure method?

merging two arrays with specified index

Submitting a form with ajax in Wordpress

Adding one microsecond to Datetime object in PHP

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

Laravel with App Engine Standard Class 'FacadeIgnitionIgnitionServiceProvider' not found

Laravel relationship belongsToMany with composite primary keys

Woocommerce product attributes with hierarchy like categories

Laravel 8 Multiple Relationships for Factory

Laravel 5.2: Unable to locate factory with name [default]

Add record for each array elements if missing in table

Script @php artisan package:discover handling the post-autoload-dump event returned with error code 255

Laravel set default language not working

Toggle between a textbox and a select using PHP

Put content of wordpress page inside div

About Contact Privacy policy Terms and conditions