I'm doing a website where companies have persons which have scores per event. And the events are ordered by city.
So by example someone can do 4 events, so they get a score for each event.
I'm using a pivot table to save the scores. ( here's a screenshot )
Now i'm loading all persons for a certain event with the following query.
$data['companies'] = Event::find($id)->city->companies;
And i'm showing them using the following structure in my blade file
@foreach($companies as $company)
{{ $company->name }}
@foreach($company->persons as $person)
{{ $person->firstname }}
{{ $person->eventscore }}
@endforeach
@endforeach
The person->eventscore is the link to the pivot table. And it's working but it's giving me the scores of that person for ALL the events.
I only want to see the score for the event that we are watching now ( you can see the id in the url bar, and i marked the id with a red arrow, Now how can i? In my view ask to only show to score for the specific event?
Thank you!