• 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 echo values of all sub keys [duplicate]

Apply session id from request header

How to display MySQL table using php and edit it in a web browser

Log file is not being written in Laravel 5.5

Issue with laravel eloquent model property

PHP Get value from JSON [duplicate]

dockerizing Laravel + vue

Pages are working fine on localhost but not running on the hosting server

(Laravel) How to delete multiple models including optional relationships?

What's the net::ERR_HTTP2_PROTOCOL_ERROR about?

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

Elastic Beanstalk with Laravel Envoy

How to get page number on dompdf PDF when using "view"

How to set a domain name with php artisan serve

Find out the name of the last script that included the current one

About Contact Privacy policy Terms and conditions