Laravel 6 FirstorCreate Increment and update column using Eloquent

Today, We want to share with you Laravel 6 FirstorCreate Increment and update column using Eloquent.In this post we will show you wordpress plugin require another plugin, hear for eloquent update column laravel 6 we will give you demo and example for implement.In this post, we will learn about laravel updateorcreate increment with an example.

Laravel 6 FirstorCreate Increment and update column using Eloquent

There are the Following The simple About Laravel How to increment only when its a new insert? Full Information With Example and source code.

READ :  Angularjs json stringify - angularjs parse json - angular to Json

As I will cover this Post with live Working example to develop Eloquent: incrementing columns without update() function, so the Laravel eloquent update column value by adding new value is used for this example is following below.

Example 1: Laravel, Update Query and FirstorCreate Method
$product_id = 12058;
$url = “”;
$desc = “Nice and Good Producs for Web”;

Products::firstOrCreate([‘product_id’ => $product_id,’ext_time’=>date(“Y-m-d H:00:00”),’name’=> addslashes($product_name)],[‘up_votes’=>0,’web_domain’=>$url,’desc’=>$desc])->increment(‘up_votes’);


very useful Laravel Methods firstOrCreate() to try and find a row, and create it if it doesn’t exist.

$tamilrokers = App\Tamil::firstOrCreate([‘name’ => ‘Tamil 10’]);

$tamilrokers = App\Tamil::firstOrCreate(
[‘name’ => ‘Tamil 10’], [‘pageview’ => 1]

$tamilrokers = App\Tamil::firstOrNew([‘name’ => ‘Tamil 10’]);

READ :  AngularJS Set Cookies Get Cookies ClearCookies

$tamilrokers = App\Tamil::firstOrNew(
[‘name’ => ‘Tamil 10’], [‘pageview’ => 1]

function downVote($id)
->where(‘id’, $id)
->decrement(‘upVotes’, 1)
->increment(‘downVotes’, 1);

How to increment and update column in one eloquent query
$user = User::find($user->user_id);
$user = new User();
$user->total_members = 1;
// Inert new user here with all related data
return $user->id;

Creating and Update Laravel 6 Eloquent

$student = Student::firstOrNew(array(‘stud_name’ => Input::get(‘stud_name’)));
$student->age = Input::get(‘age’);

useing updateOrCreate
$student = App\Student::updateOrCreate(
[‘lastname’ => ‘chovatiya’, ‘destination’ => ‘surat’],
[‘age’ => 38]

Web Programming Tutorials Example with Demo

Read :


You can also read about AngularJS, ASP.NET, VueJs, PHP.

READ :  Laravel Pass Data To All Views Example

I hope you get an idea about laravel 6 update method.
I would like to have feedback on my blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Leave a Comment