• 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

How do I get friend list from Friends table with counts of friends of my friends

laravel controller function parameters

xdebug 3 not working in ubuntu 20.04 with docker

Using PHP to connect to a remote MSSQL database

How to set a domain name with php artisan serve

Remove categories with all childs derived from parent category

XSS attack still works despite htmlspecialchars() doing its work

How to to send mail using gmail in Laravel?

SQLSTATE[HY000]: General error: 1 table posts has no column named *

Override default Auth routes in Laravel 7

Laravel Get Days In Month From Month Number?

OctoberCMS / Anonymous Global Scope

Unable to uninstall brew php from homebrew

how to youtube api data to print in toolset metabox using a button click before save-post

How to make Canonicals with PHP

About Contact Privacy policy Terms and conditions