• 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

selected value from the listbox in php

(Cache::lock()) -> get() -- Under what conditions does it return false?

How to change product Image when variables are selected in Shop and Archive Pages?

Mysqli Output to a table

How to connect to MSSQL Server with PHP from Ubuntu 18.04?

How to make autocomplete work in foreach php loop? (vscode, intellisense)

How to send image,audio or video through the WhatsApp API - PHP

Image upload not working through ajax Laravel

PHPUnit 7: Failed asserting that exception of type InvalidArgumentException is thrown

carbon generated datetime not stored correctly into the database

insert multiple rows in a saveall in cakephp

How to increase the PHP upload limits [duplicate]

Split a string array into pieces

yii2 and mssql insert varbinary into model

I'm trying to use curl with php but getting this error:Could not resolve host: Bearer

About Contact Privacy policy Terms and conditions