• 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

Override default Auth routes in Laravel 7

CodeIgniter force_download is not working

How to put php code inside opening and closing shortcodes

Laravel relationship belongsToMany with composite primary keys

How to get quarter for future date using Carbon?

Laravel Displaying image from database

How to access a var with "-" in PHP [duplicate]

Saving Data from form to database using AngularJS and php

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

Get WooCommerce products from specific category

Laravel multi auth - Authentication user provider [] is not defined

Attempted to call an undefined method named "get" of class "MailController"

How to get transaction details in notify_url page in paypal

How to remove from a multidimensional array all duplicate elements including the original?

Laravel Schedule not sending email

About Contact Privacy policy Terms and conditions