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

Can find a way to get this query
CMS Joomla: How to clear joomla cache without using admin pages?
ffmpeg not creating video from images
Php foreach remove dublicate using value [duplicate]
accessing results outside of while and for loop php
Jumping back outside of a switch statement
“jqueryrotate” plugin .Rotate and save the image to a file
length of string does not match what is printed by var_dump() in php
External Server mysql_connect No route to host
php check if link clicked
ACF Nested Repeater Fields with a Conditional to select a repeatable sub fields
PHP creating 2 rows and not checking input
angular $http gracefully handling errors
Returning only one column in json from eloquent relationship using eager loading
Formatting Arguments in Soap Clients
PHP regex +(plus) metacharacter

Categories

HOME
php
tomcat
angular-ui-grid
eclipse-plugin
bokeh
concurrency
plaid
nsview
fogbugz
bittorrent
google-search-console
port
bellman-ford
lapack
responsivevoice
jquery-file-upload
django-rq
max-msp-jitter
pywinauto
rest-assured
uima
office-ui-fabric
renderscript
spyder
workday
kaggle
pymongo
amazon-sns
candlestick-chart
quartz.net
react-dnd
points
npoi
tsung
d3.js-v4
delayed-job
plantuml
java-stream
textmate2
testlink
django-crispy-forms
assemblies
spring-restcontroller
suds
sendinput
type-inference
docker-ucp
gcal
android-5.0-lollipop
knockout-2.0
datediff
palindrome
asp.net-web-api-routing
popen
glassfish-4.1
kendo-editor
business-rules
dymola
google-shopping-api
rational-performance-test
livecycle
pyaudio
seccomp
wolfram-language
odp.net-managed
strpos
smart-tv
cfwheels
mixins
replicaset
ssmtp
mod-auth-openidc
tkx
famo.us
lmax
git-reset
csslint
cidr
gpu-programming
windows-taskbar
sensormanager
jmenubar
mp4parser
lru
chartfx
dibs
jbox2d
reentrancy
ntlmv2
significant-digits
ckeditor.net
lynx
onconfigurationchanged
clearinterval
hardcode
opends
wcf-callbacks
expression-web
delphi-prism
boost-foreach
tablet-pc
ognl
bucket
processors
main-method
eai
iphone-sdk-3.1.3
synthesizer

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile