php


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'));

Related Links

how to inject a module within another module by zend framework 2?
How to gather form data in a single cell of the database?
Laravel “At Least One” Field Required Validation
Login with ajax not working
Wordpress Custom Post Type Form Redirects to Page Not Found
Laravel 4 cannot drop foreign key
MySQL better approach to check duplicate entry
Storing images on linux
Update HTML table every 5 seconds with mySQL, and PHP?
Bllim DataTables in Laravel 4 throws undefined getQuery() exception
Written html source code in downloaded file from php page
Making a simple search engine php mysql
Make a different IF depending on which page the user came from
PHP Output (function swap) [closed]
spl_autoload_register and properties of the $class variable
PHP Function “opendir()” in Wordpress. Works in one file, but not in other

Categories

HOME
jboss
entity-framework
postgresql-9.4
transactions
devexpress
tabs
mirc
gallery
linker
share
angular-meteor
firebase-database
graphql-js
cisco
cqrs
alljoyn
csrf
sslhandshakeexception
xbox360
bnf
pywinauto
vmware-workstation
google-sites
string-formatting
http-authentication
pe
dashdb
qa
candlestick-chart
chronicle-queue
ratio
splunk-query
envoy
windows2012
opnet
nsmutablearray
cucumber-junit
om-next
image-optimization
android-canvas
microsoft-ui-automation
recovery
imgur
virtual-memory
apache-toree
jshint
viewmodel
beeline
extjs4.1
iptv
deedle
http-basic-authentication
connect-direct
glassfish-4.1
rcharts
haraka
system.web.optimization
p6spy
openseadragon
groovyfx
swiffy
i2b2
onepage-checkout
phpquery
ambiguity
wso2ml
swagger-maven-plugin
clarion
mxe
signed
maven-shade-plugin
password-recovery
xml-signature
nesper
quantify
category-theory
webautomation
redpitaya
zend-search-lucene
jack
iosched
strcmp
compiler-flags
illuminate-container
jacob
jquery-lazyload
image-formats
kolite
gwt-celltable
hungarian-notation
ios-4.2
cassini
3-tier
oracle-pro-c
yahoo-maps
iphone-sdk-3.1.3
efs

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App