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

How to load view in a view CodeIgniter
Getting tweets by hashtag - cannot get older tweets using API v1.1
nested while loops php mysql
User Following System in Laravel
Laravel 5: Retrieve data from dispatched command
Showing blob pdf in php
undefined variable php mysql
Laravel Eloquent: How to show a few articles from each categories
Magento model class rewrite not working
What are these for: $this->foo()->bar(); and why do you use them and how can you use them?
Converting pseudo-namespaced classes to use “real” namespace
What is use and Benefit of Yii FormElement Template
How to use in Wordpress other menu for all pages under slash?
How to convert .m4a to .mp3 in either PHP or Python [duplicate]
PHP search array and return only first value that meets criteria
how can i get values from serialized form?

Categories

HOME
knockout.js
list
typelite
barcode-scanner
kendo-dropdown
bots
transactions
websocket
hyperledger
javafx-8
mithril.js
tup
port
yahoo
xades4j
nexus3
cuba-platform
trace32
async-await
temperature
nest-api
unity-container
weex
neo4j.rb
altium-designer
device
sipp
oracleforms
django-import-export
bonita
knights-tour
android-collapsingtoolbar
kendo-listview
gnu-classpath
textmate2
subclassing
jade4j
fastlane
aurelia-http-client
task-parallel-library
utf
google-prediction
git-tfs
permission-denied
uiautomatorviewer
nusoap
dmarc
nsdata
xcode8-beta4
wolfram-language
apple-configurator
sharepoint-apps
flipclock
enunciate
cryptojs
mixins
gitlab-omnibus
ngcordova
textscan
scala-macros
azure-xplat-cli
subfolder
htmltidy
phonegap-facebook-plugin
adhoc-polymorphism
rubber
storing-data
quantify
category-theory
rpg
neo4jphp
webaii
oxygene
spring-security-acl
saga
eclim
frontbase
tnt4j
ofstream
linkbutton
xalan
chronometer
netstream
yuidoc
gwt-celltable
differentiation
nosetests
ccnet-config
outlook-2007-addin
aspbutton
google-translator-toolkit
tacit-programming
parentid

Resources

Encrypt Message