• 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

Detect if PHP session exists

shell errors running php exec

How to edit Records using CodeIgniter

How to create a individual template for page or post in custom plugin?

How to render html from a @foreach loop in a textarea

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

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

selected value from the listbox in php

How to programmatically find public properties of a class from inside one of it's methods

Object of class stdClass could not be converted to string error

Passing PHP JSON to Javascript: echo json_encode vs echo json declaration

Script @php artisan package:discover handling the post-autoload-dump event returned with error code 255

PHP: Calling MySQL Stored Procedure with Both INPUT AND OUTPUT Parameters (NOT "INOUT")

google content api for shopping

How to to send mail using gmail in Laravel?

About Contact Privacy policy Terms and conditions