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

Error while uploading file to PHP and displaying it using fpdf
How can I sanitize custom CSS, without it breaking?
Symfony transform ChoiceType in CheckboxType
Display variable contents with drupal_set_message
Failed loading xdebug.so undefined symbol zend_sort
Memory exhausted at 1.6G even with ini_set('memory_limit', '-1')
how to get most popular articles from model and order desc
If statement with multiple condition checks not working properly
PHP Returning two different times
Laravel setter injection
Phalcon - render controller from view
Swift Error : Error Domain=NSCocoaErrorDomain Code=3840 “ Problems with my Login Controller ”
Fatal error: Call to undefined method CI_DB_mysql_driver::group_start()
Why echo failed on $rowcount?
Data table with in line create
Display images from WordPress post

Categories

HOME
hpoo
spring-data
magento-2.0
elisp
flurry
openfoam
impala
u-boot
siesta
heuristics
buffer
angular4
vmware-workstation
boomi
xsl-fo
angular2-highcharts
anova
channel
web-push
unordered-multimap
gravity-forms-plugin
ccavenue
annotation-processing
basic-authentication
copy-protection
steam-web-api
argv
appcode
express-session
pdfminer
keyboard-layout
twilio-php
django-smart-selects
iscroll
imgur
robust
virtual-memory
moinmoin
common-table-expression
cyanogenmod
head.js
visual-format-language
gnome-terminal
stateless-session-bean
connect-direct
swiperefreshlayout
perl-data-structures
email-injection
bpms
dcount
nvda
spring-mongo
dojo-build
android-async-http
gulp-uglify
voronoi
arbre
auto-generate
apple
wso2ml
ampersand
ocmockito
gflags
datagridcomboboxcolumn
inputbox
mobile-country-code
distributed-r
rails-api
tabletools
map
nosql-aggregation
mod-perl
lync-2010
code39
facebook-game-groups
pbkdf2
san
.net-remoting
jacob
gprof
onconfigurationchanged
getopt-long
representation
mediacontroller
tablet-pc
printqueue
git-log
solandra
explicit
aggregator
data-retrieval

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