• 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

Which is faster php date functions or carbon?

How to Mock the Request Class in Laravel?

Prestashop webservice API creating cart rules

PHP Imap , php 7.4.3 on mac osx catalina

Wordpress how to get the post thumbnail inside a figure tag

Call to a member function givePermissionTo() on null

woocommerce_wp_select options array from product attribute terms

Laravel views are showing from cache on one server but works fine on other server

How to reset Laravel AuthManager/guards in between API calls in tests?

OAuth2 Token PHP

Smarty if isset

How to KeyBy where multiple items have the same key

GRPC installed successfully on ubuntu but php is looking for it in another folder

PHP: Insert marker every 3 iterations

How to override header set in Apache config with more specific header in a virtual host

About Contact Privacy policy Terms and conditions