• 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/docker-compose/redis - Class 'Redis' not found

Can't exclude directories from .htaccess mobile redirect?

Add record for each array elements if missing in table

Python - Include another Python script

How to get result of the formula on import xlsx with maatwebsite using Laravel? I get formula and not value of the formula

Confirm Leave on External Links in Wordpress

Laravel 4 Redirect::back() not going to previous page (refreshing current page)

PHP: How to solve ob_start() in combination imagepng() issue?

Make Calculator - When Button clicked the No shows in Textbox.

Display the WooCommerce product price inside a custom function

Laravel: Why is my variable not being set while it's in the construct function of the controller?

Yii2 select2 database exception number of bound variables does not match number of tokens

Show only featured products in Woocommerce shop page

Using spatie/media-library, how to rename a collection of uploaded files?

Xdebug in Laravel is not working with VSCode

About Contact Privacy policy Terms and conditions