Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

1.3K
Views
BadMethodCallException: Method Illuminate\Database\Eloquent\Collection::orderBy does not exist

When i try ordernate the output data using orderBy() eloquent's method, i view the follow message: BadMethodCallException: Method Illuminate\Database\Eloquent\Collection::orderBy does not exist. in file C:\xampp\htdocs\cerusbank\vendor\laravel\framework\src\Illuminate\Macroable\Traits\Macroable.php on line 103.

The following is my method I'm working on:

public function getCardStatements(Request $request){
       if($request->id){
           $cardStatements = Card::with('statements')->where('id', $request->id)->get();
           return response()->json($cardStatements->orderBy('statements.registration_date', 'asc'));
        }
        return response()->json(array('return'=>false));
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

After using ->get(), this becomes a collection. You will need to use methods from collection. orderBy doesnt exist in collection. You can use sortBy instead.

Here are all the available methods on collection you can use. https://laravel.com/docs/8.x/collections#available-methods

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!