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'));
yii, show records from different tables with same structure
count in model scopes() function
PHP Best Practice to Update one record and delete another record
Drupal 7 commerce module billing country selection based on user
Hiding Server Version Not Working [closed]
angularjs ng-click or ng-init? php variables
How can I “register” a static reference to an external variable from within a class [duplicate]
running php shell_exec WITHOUT returning results to browser?
Autofill textbox (php) [closed]
How to make PHP for loop with condition?
Incorrect timestamp in phpmyadmin db
Does first() return a collection in Laravel? Can i access the properties directly without using toArray()?
if ELSE statement not working correctly in while loop
How to add post thumbnail in a nested list ordered by year and month in wordpress
PHP's exec() printing output — doesn't seem to follow specs
PHP Mysql ranking