• 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

Symfony redirect if already loggedin from login page

Trying to mock an http client that is inside a controller, using phpunit, but it doesn't work

Target class controller does not exist - Laravel 8

get folder directory from input type file - PHP

Sort multidimensional array by column value within a column

How can I pass the list to the component variable in Laravel?

Fatal error: Array callback has to contain indices 0 and 1

How can I get user id from session in javascript?

Filter WooCommerce products with post__in and additional meta queries

WooCommerce - unset "<product> removed notice…" on cart page

What is PHP's equivalent of JavaScript's "array.every()"?

how to redirect the user back to desired URL after login page in PHP?

PHP rotate matrix counter-clockwise

Parsing JSON File to array in PHP

Laravel set default language not working

About Contact Privacy policy Terms and conditions