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

How to retrieve all table names from database?
PHP - How can i use str_replace in that situation?
get the value of a child
how to use my description(meta description) as a second title in joomla2.5
Can't retrieve data from MongoDb
Where is php.ini file of php_fpm?
laravel migration creates different schema
How to create facebook page with PHP or CURL?
How to convert INR to USD before passing to paypal in opencart
How to know the Dynamodb updateItem response status in AWS SDK for PHP
How can I test why sendmail / php isn't working?
Retrieve table data from another webpage using PHP
Extremely confusing (And infuriating) PHP/HTML problems
What is the facebook.com/sharer.php ios/android url schema for mobile websites?
zf2 oauth2 catching extra params
pagination limit images per page

Categories

HOME
cocoapods
openshift
firebase
generics
automapper
xcode
barcode-scanner
couchdb
hdfs
website
cypher
gentelella
linker
mithril.js
phpseclib
anchor
jpa-criteria
gtk
scrape
match
getopenfilename
colors
multi-step
hidden
office-ui-fabric
adobe-illustrator
angular2-highcharts
generator
environment
managed-c++
adapter
spring-annotations
dnsmasq
payeezy
bootstrap-sass
assert
hdiv
icepdf
sendinput
ipp-protocol
icecast
nusoap
lightning-workbench
sesame
gmaps.js
openerp-6
oid
ternary-operator
controllers
yui3
metabase
java-2d
xmlbeans
data-management
visual-studio-monaco
wolfram-language
gnucash
uibinder
mathnet
preferenceactivity
flipclock
android-mapview
extend
wlanapi
green-threads
relational-model
abstract-factory
wicked-gem
web-api
text-align
camus
ssmtp
kognitio-wx2
createfile
famo.us
symja
cakephp-2.2
zend-mail
back
lumia-imaging-sdk
accessory
incognito-mode
sqlbindparameter
meteorite
strdup
discovery
dojo-1.9
stretch
instance-variables
wndproc
live-wallpaper
sfinae
border-box
viewpagerindicator
quartz-core
yuidoc
fork-join
kext
mediacontroller
rtd
airprint
bll
dip
suphp
jdownloader
aspbutton
facebook-fbml
tacit-programming
rtti
html-generation

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