• 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

PHP/HTML: Creating A SubMenu

calling server using nusoap with complextype

insert multiple rows in a saveall in cakephp

Create a new line whenever an array value reaches more than 10 characters

how to get value from array in laravel

Access relation of pivot table in Laravel

Target Laravelista is not instantiable

How to get array values using foreach in laravel

How to override header set in Apache config with more specific header in a virtual host

How to create a cookie to store the timestamp of when a page is first loaded with php

How to unlink image from folder?

PHP Fatal error: Class not found - PHPUnit

Cut an arabic string

Getting output of MS stored procedure on php call

if statement inside concatenation

About Contact Privacy policy Terms and conditions