0

How does one execute an operation with Slim/Illuminate to update mysql database row and add +1 or -1

$user->update(['points' => +1]);
Barmar
  • 741,623
  • 53
  • 500
  • 612
Jack Dnls
  • 13
  • 4

1 Answers1

0

Try this:

$user->increment( 'points' );
$user->decrement( 'points' );
Pedro M. Silva
  • 1,298
  • 2
  • 12
  • 23
  • Thank you very much! Is there a place I can read & learn stuff like this? Would like to learn & solve a problem on my own. – Jack Dnls Mar 01 '16 at 17:52
  • Regarding Illuminate, which is a component native to Laravel, you can learn a lot by reading it's documentation, which is very complete and a great source of information: https://laravel.com/docs (particularly the Database and the Eloquent ORM sections in the bottom of the sidebar). As for problems in general, experience and lots of trying and doing stuff is the best advice I could give. Start by doing things you know and then add small bits that you don't know, over and over again. :) – Pedro M. Silva Mar 01 '16 at 18:52
  • Cheers mate. Will take a look – Jack Dnls Mar 01 '16 at 19:29