search

Home  >  Q&A  >  body text

Laravel's Eloquent ORM query condition is sorted by a certain field in descending order

$product = Product::all()->take(50);

Query 50 pieces of data. How to sort by a certain field in descending order

给我你的怀抱给我你的怀抱2809 days ago730

reply all(2)I'll reply

  • phpcn_u1582

    phpcn_u15822017-05-16 16:58:06

    $product = Product::where([])->orderBy('created_at','desc')->skip($pos)->take($limit)->get();

    reply
    0
  • 大家讲道理

    大家讲道理2017-05-16 16:58:06

    After reading your two recent questions, they were both because I didn’t read the document~~

    reply
    0
  • Cancelreply