• 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

disable two buttons after clicking another button

MySQL - Connection failed: No route to host

PHP 8.1: strftime() is deprecated

php echo xml documents with header

Yii Ajax Submit button

Add bold text and line break into Laravel Notification Email

Uploading video to Youtube using Youtube Data API V3 and Google API Client PHP -- getting 401 (unauthorized) message

Check if a string contain multiple specific words

MySQL upgrade causing unexpected results on simple WHERE clauses

phpunit - mockbuilder - set mock object internal property

how to search for a file with php

Laravel 8 Multiple Relationships for Factory

Access denied for user 'homestead'@'localhost' (using password: YES)

Maatwebsite Excel 3.1 : how do I skip duplicate data when imported?

PHP: Calling MySQL Stored Procedure with Both INPUT AND OUTPUT Parameters (NOT "INOUT")

About Contact Privacy policy Terms and conditions