• 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

Get sum of arrays inside array

str_word_count() function doesn't display Arabic language properly

Laravel Blade checkbox not checked

Woocommerce redirect after add-to-cart error

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

Laravel Unresolvable dependency resolving [Parameter #0 [ <required> $method ]] in class GuzzleHttpPsr7Request

Convert PHP array into HTML tag attributes separated by spaces

args[max_input] woocommerce if statement confused

correct PHP headers for pdf file download

Cross-Origin Resource Sharing (CORS) witth Laravel and Vuejs

Message: Set sys_temp_dir in your php.ini after installed composer

Laravel Schedule not sending email

Unsure why I am getting: Number of variables doesn't match number of parameters in prepared statement

Google Calendar API batch request PHP

Can we define variables in `.tpl` files?

About Contact Privacy policy Terms and conditions