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!

  
"
answer1
  
  
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