• 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 insert data from multiple select dropdown values into database?

PHP my timezone is no setting up in PHP.ini File in xampp

PHP: set a (deep) array key from an array [closed]

Transpose and flatten two-dimensional indexed array where rows may not be of equal length

Nginx disallowing execution of PHP in uploads directory with Magento

passwordless LDAP login and get user information using Kerberos ticket in PHP

Laravel Route issues with Route order in web.php

Download & Save Zoom Recording in directory by PHP

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

PHP: Print caught exception like Xdebug

Symfony 4: "Autowire: you should configure its value explicitly."

How to get AJAX to post on second page?

phpMyAdmin ERROR: mysqli_real_connect(): (HY000/1045): Access denied for user 'pma'@'localhost' (using password: NO)

How to convert binary string to normal string in php

Laravel: HTML in notification

About Contact Privacy policy Terms and conditions