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

Wrong encoding with MySql
How can I validate a string in this format: p[1 or more numbers]?
Making non square image render as square image without stretching
How to scan directories within directories in a PHP loop
Differences between PHPExcel and PHPExcelReader [closed]
Passing html form data to php isDomainAvailible function [closed]
POST Uint16Array, work on the array using PHP
Codeigniter shows OpenSSL error whith GMail
Modify existing code
I can't set cron job
How Get Value from multidimensional array in php [duplicate]
PHP - Search a string for specific values, return related text
Concerned about the performance of PHP
importing csv files into database
Rename Buit-in php Functions without Using PECL Extension
FB Ads API (#17) User request limit reached

Categories

HOME
opencart
verification
writefile
initialization
vsts-build
tfs2015
tibco
azure-data-lake
mithril.js
jpa-criteria
msmq
fasm
live-streaming
smartgwt
bundler
pinterest
pickle
tfsbuild
significance
jest
azure-machine-learning
akka-persistence
weex
kaggle
ratio
sap-lumira
credit-card
rust-cargo
payeezy
redgate
django-crispy-forms
cartopy
elastica
gitolite
python-jira
resampling
get-event-store
minikube
fluid-mac-app-engine
latexml
qvtkwidget
return-type
openstack-glance
asp.net-web-api-routing
wikimapia
dtd
alertify
zend-server
nrf51
perl-data-structures
maatwebsite-excel
oid
gawk
yui3
okio
svnserve
dpkg
qpixmap
yii2-model
facebook-ios-sdk
exists
utf-16
persistent-object-store
gwt-syncproxy
wepay
outlook.com
directx-9
extend
featuretoggle
darwin
quercus
tkx
sql-processor
vs-unit-testing-framework
android-2.3-gingerbread
distributed-r
network-printers
senchatouch-2.4
xmi
map
mousemotionlistener
hints
indesign-server
bcdedit
contextswitchdeadlock
towers-of-hanoi
arrow
pcspim
play2-mini
cewolf
active-record-query
j2mepolish
principles
browser-based
html-components
google-translator-toolkit
ppc
fuzzy-comparison
tso
motif

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App