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.

 

author-image
Facebook Github
A web enthusiastic, a self-motivated full-stack software engineer from Dhaka, Bangladesh with experience in developing applications using Laravel , React and Vue js