SOLVED What is fix for sprunje: InvalidArgumentException: Order direction must be "asc" or "desc"

Its been over a year since I had User Frosting running. Got it running yesterday. Tried firing up my sprinkle from last year and it reports this error — last year same code ran without this error. I’m guessing something in the framework has been updated.

Any insight where I need to add the sort order or what the syntax might look like? The file is in github here …

https://github.com/frankfont/uf-sprinkle-account-graphs/blob/master/src/Sprunje/UsersActivitySummaryViewSprunje.php

Thanks in advance for any insights!

[Thu May 28 23:51:11.182387 2020] [php7:notice] [pid 20] [client 172.20.0.1:33524] LOOK FAILED getApiGraphData for users_activity_summary_view_sprunje: InvalidArgumentException: Order direction must be "asc" or "desc". in /var/www/html/UserFrosting/app/vendor/illuminate/database/Query/Builder.php:1812
Stack trace:
#0 /var/www/html/UserFrosting/app/vendor/illuminate/support/Traits/ForwardsCalls.php(23): Illuminate\\Database\\Query\\Builder->orderBy('users.user_name', 'activities.user...', 'activities.type')
#1 /var/www/html/UserFrosting/app/vendor/illuminate/database/Eloquent/Builder.php(1356): Illuminate\\Database\\Eloquent\\Builder->forwardCallTo(Object(UserFrosting\\Sprinkle\\Core\\Database\\Builder), 'orderBy', Array)
#2 /var/www/html/UserFrosting/app/sprinkles/uf-sprinkle-account-graphs/src/Sprunje/UsersActivitySummaryViewSprunje.php(42): Illuminate\\Database\\Eloquent\\Builder->__call('orderBy', Array)
#3 /var/www/html/UserFrosting/app/sprinkles/core/src/Sprunje/Sprunje.php(159): UserFrosting\\Sprinkle\\UfSprinkleAccountGraphs\\Sprunje\\UsersActivitySummaryViewSprunje->baseQuery()
#4 /var/www/html/UserFrosting/app/sprinkles/core/src/Util/ClassMapper.php(41): UserFrosting\\Sprinkle\\Core\\Sprunje\\Sprunje->__construct(Object(UserFrosting\\Sprinkle\\Core\\Util\\ClassMapper), Array)
#5 /var/www/html/UserFrosting/app/sprinkles/uf-sprinkle-account-graphs/src/Controller/ApiController.php(32): UserFrosting\\Sprinkle\\Core\\Util\\ClassMapper->createInstance('users_activity_...', Object(UserFrosting\\Sprinkle\\Core\\Util\\ClassMapper), Array)
#6 /var/www/html/UserFrosting/app/sprinkles/uf-sprinkle-account-graphs/src/Controller/ApiController.php(69): UserFrosting\\Sprinkle\\UfSprinkleAccountGraphs\\Controller\\ApiController->getApiGraphData(Object(Slim\\Http\\Request), Object(Slim\\Http\\Response), Array, 'users_activity_...')
#7 [internal function]: UserFrosting\\Sprinkle\\UfSprinkleAccountGraphs\\Controller\\ApiController->apiGraphUsersActivitySummaryView(Object(Slim\\Http\\Request), Object(Slim\\Http\\Response), Array)
#8 /var/www/html/UserFrosting/app/vendor/slim/slim/Slim/Handlers/Strategies/RequestResponse.php(40): call_user_func(Array, Object(Slim\\Http\\Request), Object(Slim\\Http\\Response), Array)
#9 /var/www/html/UserFrosting/app/vendor/slim/slim/Slim/Route.php(281): Slim\\Handlers\\Strategies\\RequestResponse->__invoke(Array, Object(Slim\\Http\\Request), Object(Slim\\Http\\Response), Array)
#10 /var/www/html/UserFrosting/app/sprinkles/account/src/Authenticate/AuthGuard.php(53): Slim\\Route->__invoke(Object(Slim\\Http\\Request), Object(Slim\\Http\\Response))
#11 [internal function]: UserFrosting\\Sprinkle\\Account\\Authenticate\\AuthGuard->__invoke(Object(Slim\\Http\\Request), Object(Slim\\Http\\Response), Object(Slim\\Route))
#12 /var/www/html/UserFrosting/app/vendor/slim/slim/Slim/DeferredCallable.php(57): call_user_func_array(Array, Array)
#13 [internal function]: Slim\\DeferredCallable->__invoke(Object(Slim\\Http\\Request), Object(Slim\\Http\\Response), Object(Slim\\Route))
#14 /var/www/html/UserFrosting/app/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(70): call_user_func(Object(Slim\\DeferredCallable), Object(Slim\\Http\\Request), Object(Slim\\Http\\Response), Object(Slim\\Route))
#15 /var/www/html/UserFrosting/app/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(117): Slim\\Route->Slim\\{closure}(Object(Slim\\Http\\Request), Object(Slim\\Http\\Response))
#16 /var/www/html/UserFrosting/app/vendor/slim/slim/Slim/Route.php(268): Slim\\Route->callMiddlewareStack(Object(Slim\\Http\\Request), Object(Slim\\Http\\Response))
#17 /var/www/html/UserFrosting/app/vendor/slim/slim/Slim/App.php(503): Slim\\Route->run(Object(Slim\\Http\\Request), Object(Slim\\Http\\Response))
#18 /var/www/html/UserFrosting/app/vendor/slim/csrf/src/Guard.php(171): Slim\\App->__invoke(Object(Slim\\Http\\Request), Object(Slim\\Http\\Response))
#19 [internal function]: Slim\\Csrf\\Guard->__invoke(Object(Slim\\Http\\Request), Object(Slim\\Http\\Response), Object(Slim\\App))
#20 /var/www/html/UserFrosting/app/vendor/slim/slim/Slim/DeferredCallable.php(57): call_user_func_array(Object(Slim\\Csrf\\Guard), Array)
#21 [internal function]: Slim\\DeferredCallable->__invoke(Object(Slim\\Http\\Request), Object(Slim\\Http\\Response), Object(Slim\\App))
#22 /var/www/html/UserFrosting/app/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(70): call_user_func(Object(Slim\\DeferredCallable), Object(Slim\\Http\\Request), Object(Slim\\Http\\Response), Object(Slim\\App))
#23 /var/www/html/UserFrosting/app/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(117): Slim\\App->Slim\\{closure}(Object(Slim\\Http\\Request), Object(Slim\\Http\\Response))
#24 /var/www/html/UserFrosting/app/vendor/slim/slim/Slim/App.php(392): Slim\\App->callMiddlewareStack(Object(Slim\\Http\\Request), Object(Slim\\Http\\Response))
#25 /var/www/html/UserFrosting/app/vendor/slim/slim/Slim/App.php(297): Slim\\App->process(Object(Slim\\Http\\Request), Object(Slim\\Http\\Response))
#26 /var/www/html/UserFrosting/app/system/UserFrosting.php(97): Slim\\App->run()
#27 /var/www/html/UserFrosting/public/index.php(24): UserFrosting\\System\\UserFrosting->run()
#28 {main}, referer: http://localhost/UserFrosting/public/users

That orderBy syntax on line 43 doesn’t follow Laravel doc : https://laravel.com/docs/5.8/eloquent#retrieving-models

1 Like

Nice — yes, needed to be refactored. Seems to only take 2 arguments now; must have been a breaking change in Laravel. I’ll check in the fix soon.

Fixed code is now in the published sprinkle. v0.1.0-beta