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'));
CakePHP3 “Helper not found” error in plugin
Laravel Eloquent extract data into custom array
Parsing HTTP POST in PHP using REGEX?
Strange file_get_contents behavior
Show loop content according to value, inside another loop
PHP glob(): At least one of the passed flags is invalid or not supported on this platform in
set session array and get the values in other pages without using database in php
get specific colunm from latest five record in the MySQL DB
Validation error message doesn't appear in View?
How to install phpChart lite library?
How to use PHP to return an image to Objective-C?
Exiting a php cron job with continue
SQL Injection with an Escaped String?
Symfony projects messing up the cache
password_verify doesn't verify hash
What would be the proper sql query to use, in order to echo from my two tables?