• 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 block shortcut in Visual Studio Code

How to show selected value using javascript in laravel

PHP array slice from position + attempt to return fixed number of items

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

Timber: Single post pagination does not work (wp_link_pages)

Laravel Route issues with Route order in web.php

mysql_result is defined but mysql_free_result warns it expected a resource

Unable to run composer install

How to make autocomplete work in foreach php loop? (vscode, intellisense)

Stop caching for PHP 5.5.3 in MAMP

VB.NET WebRequest with PHP POST

Problem with fetching data from database in Laravel

how to identify the web server name of remote host

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

PHP Fatal error: Class not found - PHPUnit

About Contact Privacy policy Terms and conditions