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

PHP RegEX is not working 100% [duplicate]
PHP multidimensional array search with provided array column (using PHP5 array_column)
Display Search Results by Column name
unable to print the value of field in mysql php
Moving reset password to backend, Yii2
Get Value Of Id From array
PHP Trying to get a specific variable from a JSON string
Receiving PHP Parse error for common.inc but the include command (indicated in the error) is not in the file
500 server error in Laravel mail send
How to add a “No results found” message using PHP?
mysqli oop return null
Docker Lavarel Storage Permission Error
OpenCart Insert/Update Products Api [closed]
Select from database where date is less than a supplied date
PHP Add every 2 items inside DIV in WordPress loop
difference between dollar prices day and yesterday up or down mysql php

Categories

HOME
opengl
oracle
macos-sierra
verification
operating-system
hid
tcsh
loopbackjs
braintree
jersey-2.0
tcp
cryptography
biztalk-2010
mosquitto
implicit-conversion
gprs
wine
mpu6050
adminlte
hdl
generator
chronicle-queue
sipp
cellular-network
multi-dimensional-scaling
acrobat
react-bootstrap-table
bonita
netbios
mapnik
epplus
sql-execution-plan
amazon-kms
identify
ms-dos
unification
ng-repeat
grails-spring-security
minikube
web-inspector
git-tfs
zend-form
bit-shift
django-static-precompiler
roracle
jgrapht
phppgadmin
solr-query-syntax
connect-direct
polymaps
swiperefreshlayout
emf-compare
petsc
yargs
openquery
data-management
fuzzer
p6spy
mathml
fragmentstatepageradapter
adp
flipclock
openmrs
android-mapview
ora-04091
srv-record
netdatacontractserializer
ampersand
tree-structure
nssortdescriptor
mxe
mutators
htmltidy
global-scope
zend-mail
treeline
rpg
zend-search-lucene
xulrunner
application-server
tnt4j
jacob
flv
unicoins
axacropdf
aero
jquery-dialog
wndproc
clearinterval
series-40
multidrop-bus
qt-mobility
kext
grails-validation
anonymous-types
odac
eventaggregator
processors
source-code-protection
icon-language
jboss-mdb
watchpoint

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App