Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Laravel 4: how to order by using Eloquent ORM

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 811
    Comment on it

    In Laravel 4.x we have many facility to use query in a easy way. We will also run raw query in laravel 4.x. Laravel 4.x also provide of using order by query using Eloquent ORM.

    We can easily understand this by seeing the example of order by:

    Example:

    $GiverInMeeting = User::find($user_info->id)->Giver()->where('status', 'pending')->orderBy('updated_at', 'DESC')->get();
    

    Here we can see User is a eloquent and we use orderBy for getting records in descending order.

    Note: In orderBy we have two parameter (DESC or ASC).DESC will give the result on descending order and ASC will give the result on ascending order.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: