• 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

Why is this PHP array not the same?

IlluminateDatabaseQueryException: SQLSTATE[HY000]: General error: 1 no such table - In clone project

Cannot connect to own websocket server when on secured domain

Get WooCommerce products from specific category

SQL to convert multiple rows into a single row of variable length

Detect if PHP session exists

PHP: Telegram Bot: Insert line break to text message

Ajax GET request fails in laravel 8

Laravel Carbon get start + end of last week?

Return new collection without modifying original collection

How to assert parameter attribute sub-structures in PHPUnit mock call expectations

How to redirect to another page after n seconds in wordpress without using javascript?

selected value from the listbox in php

Clients authentication and user authentication with laravel

How to get quarter for future date using Carbon?

About Contact Privacy policy Terms and conditions