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

PHP optimizing queries in customer class
html email is not displaying in proper format in email (except gmail) when I send it using php mail function
Wordpress one-page template with dynamic portfolio section
google cloud dns, php api, adding multiple cname
How to get word between particular symbols in string
change field value using jquery
Regular expression - return split matches
Php - Sort associative array by key
MySQL selecting single data?
PHP: How to ensure, an array contains all combinations of values
Using common functions (controllers) in code igniter
CakePHP 3.1 routes with conditional statements
I'm getting the error 'Cannot send session cache limiter' from php [duplicate]
How to get a shell command to work in php with exec
Mocking a method within tested class
PHP arithmetic operation where number starts with zero

Categories

HOME
paypal-ipn
risk-management
mosquitto
drag-and-drop
capistrano
cdi
selection
log4j2
xamarin-zebble
android-externalstorage
freertos
asciimath
android-contacts
codefluent
parceler
jitsi
workday
mime-types
function-points
javax.persistence
materialize
riotjs
nsmutablearray
wampsharp
gsp
mongoengine
serversocket
directfb
dreamfactory
spinner
unification
sbjson
windows-store
grails3.2.0
vb.net-to-c#
coverage.py
minikube
moinmoin
asihttprequest
realstudio
sigsegv
android-webservice
watir-webdriver
degrees
controllers
ipywidgets
java-2d
jpda
piping
jeasyui
textblock
management-studio-express
in-app-billing
variable-length-array
mixins
green-threads
modern.ie
componentart
wicked-gem
clarion
mgwt
sablecc
ildasm
xml-signature
dmake
inputbox
forio-contour
refit
strdup
django-settings
libxml-js
tnt4j
ui-design
ofstream
oembed
itunes-sdk
2d-vector
email-verification
zend-pdf
server-name
kaazing
kobold2d
infopath-2007
motodev-studio
play2-mini
kext
dip
explicit
server-load

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile