Laravel 6 Update Increment column

Today, We want to share with you Laravel 6 Update Increment column.In this post we will show you laravel 6 update timestamp, hear for increment by update field in laravel we will give you demo and example for implement.In this post, we will learn about How to increment and update column in one eloquent query with an example.

Laravel 6 Update Increment column

There are the Following The simple About How to increment a column using Eloquent Model in Laravel 6 Full Information With Example and source code.

As I will cover this Post with live Working example to develop increment and decrement value in laravel 6, so the laravel call to a member function increment() on integer is used for this example is following below.

MySQL Database Table fields increment in laravel 6

Movie::where('movie_id', $movie->id)
  'pageview'=> DB::raw('pageview+1'), 
  'last_pageview_increased_at' => Carbon::now()

additional columns to update during the operation:

Movie::where('movie_id', $movie->id)
->increment('pageview', 1, ['last_pageview_increased_at' => Carbon::now()]);

Increment columns in laravel 6

using update() methods

   ->where('status', 1)
       'runs' => DB::raw('runs + 2'),
       'fifty' => DB::raw('fifty + 10'),
       'sadi' => DB::raw('sadi + 13'),
       'bevdi' => DB::raw('bevdi + 5'),

how to use increment() and decrement() in laravel

$query = DB::table('movies')


increment or decrement a column value in laravel?

plus 1 By Using increment()

public function pageviewIncrement($id = 1)

plus 1 By Using update()

public function pageviewIncrementWithUpdate($id = 1)
	Movie::where('id',$id)->update(['pageview' => DB::raw('pageview+1')]);;

minus 1 By Using decrement()

public function pageviewDecrement($id = 1)

minus 1 By Using update()

public function pageviewDecrementWithUpdate($id = 1)
	Movie::where('id',$id)->update(['pageview' => DB::raw('pageview-1')]);;

Laravel 6 Eloquent Incrementing columns

Eloquent: incrementing columns without update() function

when Update the row

$customer = Movie::find($movie_id);
$pageview = $customer->pageview + 1;
$customer->update(['pageview' => $pageview]);

using increment


using increment

Movie::find($movie_id)->increment('pageview', 50);

using decrement

Movie::find($movie_id)->decrement('pageview', 50);

Web Programming Tutorials Example with Demo

Read :

Also Read This ๐Ÿ‘‰   Vue js Laravel Image Upload Example Tutorial From Scratch


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

I hope you get an idea about laravel increment column by 1.
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.