DB::table('New_Themes')
->where('id', $id)
->decrement('upVotes', 1);
DB::table('New_Themes')
->where('id', $id)
->increment('downVotes', 1);
...
I have the update query, so I have at least 4 of this(where and increment stuff) which is repetitive and it takes time to search on an on.
My Question: There is any shortcut like doing so
DB::table('New_Themes')
->where('id', $id)
->decrement('upVotes', 1);
->increment('downVotes', 1);
but it doesn't work, any idea how to make it simpler?
Second Question: How to use firstOrCreate method in Laravel, I need this feature to make my code easier. But i don't know how to integrate it with models, controllers.
Ex. $flight = App\Flight::firstOrCreate(['name' => 'Flight 10']); (from documentation)
What kind of variable is $flight, boolean or ...?, Any explanation will be very helpful for me, cause the laravel documentation lacks detailed information.