Sign Up

Sign In

Forget Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

You must login to ask question.

Developers Map

How to use order by with pluck function in laravel

  • 1

Laravel is a most common framework. it is very easy to use and learn.if when we want to get selected column like id and name then we use pluck function. if we want to use order by on a specific column then you should use below code

Use Below Code :

$data = YOURTABLE::orderBy('column_name','asc')->where('condition')->pluck('column_name', 'id')->toArray();

Example :
$data = users::orderBy('name','asc')->where('status','true')->pluck('name', 'id')->toArray();
Leave an answer

Leave an answer

Browse