Trying to use Collect.js in contoller

Posted 1 year ago by tsaicharlie93

Hi, I am new to laravel. I am getting an error while using collect.js function that I cannot figure out.

my code in my controller is:

$users = User::all();
    $collection = collect($users);
    dd($collection.sortBy('first_name'));

my error is :

Call to undefined function App\Http\Controllers\sortBy()

Can someone tell me what is wrong?

or is collect.js not suppose to be used this way?

Thanks

Please sign in or create an account to participate in this conversation.