• 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

Laravel Unknown Column 'updated_at'

How to install php yaml on CentOs?

Accessors (Getter) & Mutators (Setter) On a Pivot Table in Laravel

Ajax GET request fails in laravel 8

PHP code for generating decent-looking coupon codes (mix of letters and numbers)

Dynamic dropdown Ajax PHP request

phpmyadmin : Depends: php-twig (>= 2.9) but 2.6.2-2 is to be installed. WHAT?

Image upload not working through ajax Laravel

PHPUnit (Phar) Fatal Error Only When Test Fails

Display specific shipping method if woocommerce product has specific acf field value

VichUploaderBundle error "Expected argument of type "File", "NULL" given" when submitting the form without selecting any file

Zig-zag scan an N x N array

Apply filter array/return terms

How do I upload a laravel project on cPanel shared hosting?

WHERE IN array binding in DB::raw laravel 5.4

About Contact Privacy policy Terms and conditions