php


Get all dara abd OrderBy specific word in laravel eloquent


how to get all data and orderBy specific word.
For example i have column name status. In the status is store for "Approved", "Pending","Rejected".
How can i sort the data like show all status "Pending" with Descending order?
This might work:
$data= DB::table('table_name')
->orderby(DB::raw('case when status= "Pending" then 1 when status= "Rejected" then 2 when status= "Approved" then 3 end'))
->get();
References
Question in stackoverflow
Laravel Documentation
you can achieve that using
$var1 = ModelName::where('status','=','Pending')->orderBy('id','desc')->get();

Related Links

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?
Passing value along with MySQL retrieved value as hidden value in JavaScript to AJAX function
Dynamic forms and PHP
PHP MYSQL Register page Validation
How LOCK works for writing logs into flat file?
PHP mysql how to relationship three tables showing outputs from different tables
Paypal - CURL response is 0 in a new server (connection time out), it's ok in the old server
Using ajax how to get data from the database in PHP?
How to check the exception thrown correctly by PHPUnit?
How to encrypt the $_GET data in php?
jquery mobile lost css with ajax post

Categories

HOME
xcode
yii
qc
swi-prolog
theano
slider
vue-resource
bittorrent
ag-grid
telegraf
swarm
feature-extraction
xbap
squirrel-sql
jpa-2.0
closures
http-authentication
cpu-usage
scheduled-tasks
wsf
akka-persistence
tableview
intel
channel
substring
backendless
jpa-2.1
router
tracing
uri
jackrabbit-oak
history.js
sfml
bitbake
substance
google-play-developer-api
actframework
rspec-rails
osx-lion
appcode
apptentive
java-stream
db2-luw
express-session
textmate2
google-now
python-sounddevice
praat
suds
distributed-caching
flipkart
hypothesis-test
contactless-smartcard
expandablelistview
absolute
viewmodel
scala-breeze
iptv
ptvs
mechanicalturk
fitbit
nitrousio
researchkit
rational-performance-test
fuzzer
jsf-2.3
meld
unsigned
gwt-syncproxy
wepay
myfaces
textpattern
dsa
enaml
apple
blockquote
ampersand
azure-xplat-cli
password-recovery
inequality
iplimage
mobile-country-code
nidaqmx
loginview
accessory
senchatouch-2.4
jchartfx
hyphen
ggts
frontbase
bcdedit
blobstorage
web-frameworks
ip-geolocation
live-wallpaper
affinetransform
airprint
regression-testing
solandra
urchin

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