Skip to content

How can put the data into an array in laravel blade javascript? #21453

Answered by comprog-ux
comprog-ux asked this question in General
Discussion options

You must be logged in to vote

I found out the way to do it.
var locations = [
@foreach ($data as $i)
[ "{{ $i->name }} " + “i " + “{{ $i->contact_city }}” + " br>” + “{{ $i->date }}” + " Anmälda: " + “{{ $i->signups_count }}” , {{ $i->lat }},{{ $i->lng }},0, “{{ $i->signups_closing_date }}” , “{{ $i->closed_at }}”,‘http://localhost:8080/app/competitions/’+{{ $i->id }}+ ‘/information’],
@Endforeach
];
And for the loop where I put out the markers:
var t=new Date();
var visa;
var ldstr=t.toLocaleDateString(); // Today’s date.
// The loop
for (i = 0; i < locations.length; i++) {
date1=new Date(locations[i][4]);
date2=new Date(ldstr);
var newLat = locations[i][1] + (Math.random() -.5) / 20;// * (Math.random() * (max - min)…

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants