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'));
XML content inside PHP variable
Store array and update record in database using codeignitor
Active page always showing as strong/bold, Code Igniter Pagination
Codeigniter array to object conversation
Why is Propel is always setting created_at and updated at to the same value?
Use the first match count of matches in select statement
Sending mail using phpmailer is showing success but not getting delivered [duplicate]
Warning: Invalid argument supplied for foreach() -> MySQL Connecting [duplicate]
Codeigniter dynamic url for pages breaks routes
How to test Doctrine Migrations?
When to hardcode data inside the source code, when to use the database, and when to use a web service?
Closing connection in order to get remaining queries to run [closed]
Multiple recipients email php
Wildcard subdomain redirecting to a file
Laravel where if statemnet
PHP file can't connect to my database?