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

'Order by' specified order in Woocommerce shortcode
woocommerce hooks warning “function not found”
How to acces value from route in symfony2
Get Value Of Table Field
redirecting a long URL to https
How to embed this php code in html?
Uncaught Error: Call to undefined function curl_init()
Multi level login by address
SELECT * FROM table WHERE `id` in … and where sum() less
Laravel: Undefined method fake on Laravel storage facades for file upload testing
Very Complex SQL Data Result Merge via PHP (Multi Dimentional Arrays)
codeigniter Insert_batch not working
How do I fix this invalid JSON that wasn't escaped? (in PHP)
PHP: how to adding date with number of month from database? [duplicate]
Illegal string offset 'class' in ( php 7.1.1 ) [duplicate]
How to Create a shortcut automatically on mobile to a website

Categories

HOME
opengl
oracle
magento2
automapper
mpdf
android-fragments
kendo-dropdown
long-integer
selenium-builder
typeerror
dji-sdk
share
google-search-console
ui-automation
port
slide
graphdb
circleci
cname
ex
max-msp-jitter
global-variables
pygobject
psql
kamailio
generator
channel
vuforia
fstar
android-cardview
annotation-processing
bobo-browse.net
audit
envoy
tightvnc
instructions
ms-media-foundation
polyml
db2-luw
wdk
redgate
pdfnet
love2d
ms-solver-foundation
identify
fastlane
xll
rdp
pyttsx
spooler
oracle-bmcs
xcode8.2
kitura
spongycastle
qvtkwidget
windows-media-player
nusoap
node-apn
winston
exc-bad-access
scala-collections
portability
wikimapia
polymaps
rustdoc
d3v4
petsc
allegro
boost-compute
google-identity-toolkit
bigdecimal
libharu
msg
jpda
jeasyui
jeditable
wif4.5
asp.net-web-api-helppages
screen-orientation
mixins
extend
sqlbase
apple
360-degrees
gql
dynamics-ax-2012-r2
darwin
ampersand
com0com
scala-swing
signed
python-c-extension
microsoft-expression-web
flurry-analytics
dc
webmethod
reference-counting
roxy-fileman
facebook-game-groups
objective-c-runtime
jquery-lazyload
notin
axacropdf
web-frameworks
examine
jsplitpane
image-formats
nsfont
acpi
nosetests
cewolf
simile
ognl
pyjamas
turbine
reliability
android-input-method
cleartype
getimagesize
eventaggregator
yahoo-maps
html-components
ppc
bucket
fxruby
inversion
suggestbox
error-detection

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