How to increment column value of table in Laravel

You can increment the column value of the table in Laravel using increment method. You can increment value by one or you can also increment the value by a specific number

Answers 1
  • Laravel increment table column value using increment() method

    //Increment view_count column value by 1 of posts table
    //Increment column view_count with a specific value
    User::find(1)->increment('points', 20);

    This code snippet is used to increment the value of a specific column of a table. You can increment value by 1 without specifying the value to the second argument of the method and you can also pass the specific number to the second argument of increment method to increase the value to the desire output.

  • Back to code snippet queries related laravel