• 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 Unresolvable dependency resolving [Parameter #0 [ <required> $method ]] in class GuzzleHttpPsr7Request

How to prevent phpmailer sending embedded image as an attachment on Gmail?

PhP how to calculate moments with variables rows

getting error while enter Command => php artisan route:list

How to create a video stream from a single dynamic image in PHP

JSON Render Issue in Date Object Laravel and PHP 7.4

Correctly determine if date string is a valid date in that format

could not find driver Debian SQL Server PHP

Laravel Sanctum CSRF not authenticating

How to fix Call to undefined method AppModelsTableName::factory?

Symfony redirect if already loggedin from login page

Entity provider not working in security.yml php symfony3.4 ({"code":401,"message":"bad credentials"}.)

add uri parameter to Route name in laravel

Doctrine 2 mapping referencing unique key

selected value from the listbox in php

About Contact Privacy policy Terms and conditions