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'));
Regex to match alphanumeric characters, underscore, periods and dash, allowing dot and dash only in the middle
Setting Facebook PHP SDK access_token with setAccessToken()
How do I modify the path used by exec in php
Broken link check while initiating cron-multi
How to format `23/05/2012` into insertable value in DATETIME column?
will users see post on their wall,if a post is made on app page
Wordpress Loop passing variables
PHP Imagick - setTextEncoding() function doesn't work
Upload PHP Code not uploading image
Why create own request object? [closed]
array declration methods in php [closed]
File extension filter when choosing file to upload
Secure file storage in a server
MySQL: Avoid selecting columns with the same userid
Can't view local images with apache
Bug in Doctrine or am I doing something wrong?