laravel-mongodb icon indicating copy to clipboard operation
laravel-mongodb copied to clipboard

orderBy doesn't work

Open sathia-musso opened this issue 4 years ago • 2 comments

  • Laravel-mongodb Version: 3.8.4
  • Laravel Version: v8.50.0
  • PHP Version: 8.0.8
  • Database Driver & Version: mongodb/mongodb 1.9.0

Description:

orderby doesn't work

Steps to reproduce

  1. $query = Model::where('blah', 'blah')->orderBy('age', 'desc');

Expected behaviour

should return a query

Actual behaviour

an exception is raised ErrorException Undefined array key "column"

Logs: Illuminate\Foundation\Bootstrap\HandleExceptions::handleError vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/Grammar.php:740

nevermind, looks like there was some issue on my code. I swear I've been testing it for a lot but it seems it was my fault

sathia-musso avatar Jul 20 '21 12:07 sathia-musso

It's working, i think you need to check your name of columns. Then you should to add "->get()" end of query. If you don't add "->get()" it returns "Jenssegers\Mongodb\Eloquent\Builder".

ifbaran avatar Aug 11 '21 08:08 ifbaran

But this does not work for yajra datatables with mongo db ....on adding order by it returns Trying to access array offset on value of type int on doing order by

apvvyas avatar Sep 16 '21 13:09 apvvyas