mardi 23 mars 2021

How to loop the data into an array in laravel blade javascript?

In my Laravel 5.3 project I have this in my controller to achieve competitions table data:

public function list(){
$data=Competition::all();
return view('map', ['data'=> $data]);
}

The route:

Route::get('map', 'Api\CompetitionsController@list');

With these lines of code i my map.blade.php (in the html area) for five columns (two posts):

<ul>
@foreach ($data As $i)
    
@endforeach
</ul>

I got printouts for five columns (two posts) like this:

1 Fälttävlan Landskrona 55.87 12.83 2 Fälttävlan Sundsvall 62.39 17.31

In my script area for the map I want to make an array containing these example five data for each post in the database table to create markers on the map. How do I do that? The $data contains everything in the DB table as not only data but column names and so on.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2QsorKl
via IFTTT

Aucun commentaire:

Enregistrer un commentaire