Update Database Using Laravel Eloquent
I have a problem updating my database, it is working fine using the general DB:: method but I think it would be better to use Eloquent. The general DB method I used (which worked): \DB::table('subscriptions')->update(array('state' => 'active')); The Eloquent method I used (and it doesn't work): $user = $request->user(); $user-> subscription-> state = 'active'; $user-> save(); Thanks for helping me!
\DB::table('subscriptions')->update(array('state' => 'active')); When you do that you're updating the state of every row. Assuming you have proper relationship setup, you do one of the below. $subscription = $request->user()->subscription; $subscription->state = 'active'; $subscription->save(); $request->user()->subscription()->update(array('state' => 'active'));
Installing PHP 7 on digitalocean
Laravel Redirect and Undefined Variabale
Replacing href value of all <a> elemnts without link with .mp3 extention
How to fix Fatal Error after consecutive calls to MySQLi_Connect?
Mysqli SELECT COUNT (*) FROM table returning false
Tooltip with MySQL query
pagination not working for taxonomy
PHP -> simplexml_load_file skip to next when error
How to correct and change a static method to a non-static method for Joomla module
How to individual print every word of a sentence in PHP? [closed]
JetBrains PhpStorm Not Resolving Server Variable?
couldn't fetch session value to another page
Edit YAML array with php Symfony2.8
preg_replace and hidden chars or hidden encoding
BelongsToMany with BelongsToMany relation [closed]
What is equivalent of strtotime in SQL?