• 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

how to identify the web server name of remote host

MySQL upgrade causing unexpected results on simple WHERE clauses

Laravel 8: Array to string conversion while calling route:list

How to loop sql table data inside a html table

How can I solve "laravel/horizon v1.1.0 requires ext-pcntl * -> the requested PHP extension pcntl is missing from your system"?

Laravel + phpunit + github actions = Failed asserting that '1' is identical to 1

PHP if in_array() how to get the key as well?

PHPUnit 7: Failed asserting that exception of type InvalidArgumentException is thrown

Refresh specific HTML content that retrieves data from MySQL

Show date difference as "20" instead of "20 years ago"

PHP 8 - libxml_disable_entity_loader() has been deprecated. How do I replace the functionality it provides?

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

php curl requesting twice

How to send image,audio or video through the WhatsApp API - PHP

Laravel: HTML in notification

About Contact Privacy policy Terms and conditions