I want to show multiple gmaps markers on dashboard. This marker data, taken from the database. I've coded like this, but it still doesn't work.
Controller
public function index()
{
$markers = Report::select('location','latitude','longitude')->get()->toArray();
// dd($markers);
return view('dashboard', compact('markers'));
}
and in blade, i made like this. This I got the reference from
How to fix it? Thank You
CodePudding user response:
SOLVED. this case can be solved by using collection map in controller
public function index()
{
$markers = Report::select('location','latitude','longitude')->get();
$markers = $markers->map(function ($item, $key){
return [$item->location, $item->latitude, $item->longitude];
});
return view('dashboard', compact('markers'));
}