Call To A Member Function Map() On Array Laravel - (Solved)

Hello artisan, in this tutorial, i will show you how to solve "call to a member function map() on array laravel" in php laravel application. You know that map returns a new array in php. If you face this error call to a member function map() on array laravel, then first we have to cast our data using collect() api rapper. Then map function will work.

See the example code of how to solve call to a member function map() on array laravel:

$users = collect($users);

$users->map(function($user) {
    //do your code
});

 

Hope it can help you.

 

#laravel