• 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

selected value from the listbox in php

500 (Internal Server Error) with Laravel & Docker [duplicate]

Log file is not being written in Laravel 5.5

is there any way to validate a field that sometime is File(image) && sometime is String(Src of same image)

SlimExceptionHttpNotFoundException

Facebook SDK error: Cross-site request forgery validation failed. Required param "state" missing from persistent data

CodeIgniter extend CI_URI undefined method

Display the WooCommerce product price inside a custom function

Assets not referencing to public folder (Laravel)

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

How to get values inside <![CDATA[values]] > using php DOM?

Invalid value in field "itemtype" in Google Search Console

How can I make a full text index of the column?

How to add automatically collapse/expand in content wordpress (single.php)?

How to get the total hour from starting time to end time in php

About Contact Privacy policy Terms and conditions