• 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 add a custom field to all Woocommerce attribute terms using add_action

How to create custom authentication in laravel 8?

How to Make Laravel Eloquent "IN" Query?

Add restriction to WooCommerce coupons by allowed user ID

Fatal error: Uncaught mysqli_sql_exception: Unknown database 'test' in ... (How do I fix that? Using PHP)

find in set in laravel ? example

How to Install Composer Require doctrine/dbal

Magento Installation SQLSTATE[HY000] [2002] No such file or directory error

Laravel s3 upload file with metadata using pre-signed url

phpunit - mockbuilder - set mock object internal property

WordPress + Nginx on non-standard port behind AWS ELB results in broken links

How to get result of the formula on import xlsx with maatwebsite using Laravel? I get formula and not value of the formula

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

How can I stop a symfony process which is listening on http://127.0.0.1:8000

PHP Include for HTML?

About Contact Privacy policy Terms and conditions