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

Trying to get property of non-object in laravel 5.2
PHP Contact Form Error on Line 7 [duplicate]
updating a field in the database through a function and calling it
Splitting strings in to array by intergers in the string using php
Laravel Socialite Login validate
MySQL - Group by for UNION query
PHP Handle missing arguments and null values in functions
Why can I not save a post with a user ID field to a database using Laravel?
IIS8 URL Rewrite multiple conditions (PHP)
Override Email Form of lexik Mailer Bundle [Smfony2]
Changing PHP-GD version
Share Dynamic Data on Facebook
String search from the end with skipping matches in PHP
Could you point how to put a button at the right side of the links by using jQuery?
Match all substrings that end with 4 digits using regular expressions
selecting MAX(val) from a sql resource in php

Categories

HOME
office365
entity-framework
plesk
azure-functions
vagrant
dotnetnuke
opencv-python
informatica
google-webmaster-tools
elk-stack
tibco
mosquitto
mithril.js
joomla3.2
angular2-template
phpseclib
scrape
nsstring
pm2
powermock
android-contacts
cloudsim
psql
adobe-illustrator
opam
conda
restier
uilocalnotification
points
echosign
matlab-app-designer
riotjs
plantuml
ms-media-foundation
netstat
xvfb
widestring
sbjson
grunt-contrib-watch
opal-framework
notesview
nuclio
rm
hibernate-ogm
maven-jaxb2-plugin
simple-schema
mongodb-aggregation
rustdoc
bpms
ternary-operator
mathjs
jsf-2.3
unsigned
simian
vaadin4spring
okta-api
univocity
in-app-billing
perceptron
variable-length-array
http.client
dsa
subview
tkx
n-tier-architecture
rubber
nesper
qt5.4
tabris
visual-studio-6
angular-ui-select
mfmessagecomposeview
two.js
code-complexity
zend-search-lucene
meteor-collections
cidr
ivalueconverter
typesafe-stack
iosched
libxml-js
indesign-server
donut-chart
red-system
ckeditor.net
linkbutton
wndproc
liveconnect
algol68
background-repeat
mvcrecaptcha
representation
simile
channelfactory
turbine
ixmldomdocument
database-cloning
code-camp
rootkit

Resources

Encrypt Message