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 Codeigniter : set Port Number for MySQL Configuration
No data sapecified error when I want to print data in function on jqplot
How to get attribute value from xml? [duplicate]
Escaping output but allowing <p> in Laravel
PHP - Sending a POST request from android turns emojis into question marks
Magento administration - error when trying to access categories (catalog - categories)
mysql select convert to zend framework select
MailChimp Unsubscribe in PHP
Running PHP on IBM/Lotus Domino server
Ignore and continue on specific Symfony2 kernel.exception event
Loop through a two-dimensional array
What are the supported values for PHP zend.script_encoding?
How to grab all the page urls through website url? [closed]
Get the Course start and expiry Date (timestart and timeend) via API Call (Moodle 2.7.2)
PHP Sum Up the value of textbox
Arabic text not displaying in datatable

Categories

HOME
knockout.js
vagrant
mousemove
tcsh
loopbackjs
ant
flurry
visualforce
ipv6
onvif
native-base
sharepoint-online
port
yahoo
lda
lc3
match
fbloginview
csrf
corona
asciimath
checkout
boomi
tfsbuild
cpu-usage
spring-ldap
exchange-server-2010
animated-gif
plyr
openbravo
tortoisehg
sfml
google-play-developer-api
mongodb-3.4
caesar-cipher
custom-keyboard
express-session
orchardcms-1.8
netstat
cargo
swfupload
netapp
get-event-store
vb.net-to-c#
viewcontroller
yoast
haar-classifier
virtual-memory
doctrine-extensions
react-intl
directwrite
deployd
scala-breeze
punctuation
msxml
sidewaffle
openerp-6
bpms
s-function
android-4.2-jelly-bean
fragmentstatepageradapter
dojo-build
jemdoc
swiffy
mercurial-extension
gridbaglayout
vim-plugin
diawi
phpquery
directx-9
nhibernate-criteria
nanomsg
directorysearcher
password-recovery
window-resize
nidaqmx
libgcc
.htpasswd
reference-counting
webaii
hotswap
boolean-algebra
progress-db
mute
postgres-xc
system-requirements
onconfigurationchanged
hardcode
nsfont
quartz-core
mmc3
server-variables
net-use
tablet-pc
nsconnection
mongrel
facebook-fbml
rational-unified-process
external-sorting

Resources

Encrypt Message