Vishaal
6 months ago
288
2
Laravel

Foreach problem

Posted 6 months ago by Vishaal

Hello,

I have foreach problem in mine project, I have 2 foreach with one if function inside it but i'm not getting the result what i must get.

what i'm trying here is build if function if the $beschikbaar->job_id and $alledienstens->id doesn't match then it must show. But this code give me result of id 2 and 3

result must be only show id 3 because the $beschikbaar->job_id content id [1 and 2]

Can anyone help me with this?

Bladecode:

                        @foreach($allediensten as $alledienstens)
                            @foreach($beschikbaarheid as $beschikbaar)
                                @if($beschikbaar->job_id != $alledienstens->id)
                                <tr>
                                    <td><input type="checkbox" class="checkbox" value="{{$alledienstens->id}}" name="checkbox[]" /></td>
                                    <td id="takenid">{{$alledienstens->id}}</td>
                                    <td>{{ \Carbon\Carbon::parse($alledienstens->date)->format('d-m-Y')}}</td>
                                    <td>{{ \Carbon\Carbon::parse($alledienstens->starttijd)->format('H:i')}}</td>
                                    <td>{{ \Carbon\Carbon::parse($alledienstens->eindtijd)->format('H:i')}}</td>
                                    <td>{{$alledienstens->kamernummer}}</td>
                                    <td>{{$alledienstens->aantalsurveillanten}}</td>
                                    <td>{{$alledienstens->locatie}}</td>
                                    <td>{{ \Carbon\Carbon::parse($alledienstens->beschikbaartot)->format('d-m-Y H:i')}}</td>
                                    <td>{{ \Carbon\Carbon::parse($alledienstens->accepttot)->format('d-m-Y H:i')}}</td>
                                </tr>
                                @endif
                                @break
                            @endforeach
                        @endforeach

$beschikbaar array

[{"job_id":1},{"job_id":2}]

$alledienstens array

[{"id":1,"user_id":3,"vaardigheid":"TDV","taal":"Nederlands","digitaal":"Ja","ervaring":"Meer dan 2 jaar","date":"2019-04-05","type":"Decentraal","starttijd":"19:15:00","eindtijd":"20:15:00","kamernummer":"H1.03","locatie":"test","beschikbaartot":"2019-04-11 00:00:00","accepttot":"2019-04-11 16:43:00","status":"uitgezonden","cronstatus":"beschikbaaropgeven","opmerking":null,"created_at":"2019-04-21 14:39:54","updated_at":"2019-04-21 22:26:28"},
{"id":2,"user_id":3,"vaardigheid":"TDV","taal":"Nederlands","digitaal":"Ja","ervaring":"Meer dan 2 jaar","date":"2019-04-05","type":"Decentraal","starttijd":"19:15:00","eindtijd":"20:15:00","kamernummer":"H1.03","locatie":"test","beschikbaartot":"2019-04-11 00:00:00","accepttot":"2019-04-11 16:43:00","status":"uitgezonden","cronstatus":"beschikbaaropgeven","opmerking":null,"created_at":"2019-04-21 14:39:54","updated_at":"2019-04-21 22:26:28"},
{"id":3,"user_id":3,"vaardigheid":"TDV","taal":"Nederlands","digitaal":"Ja","ervaring":"Meer dan 2 jaar","date":"2019-04-05","type":"Decentraal","starttijd":"19:15:00","eindtijd":"20:15:00","kamernummer":"H1.03","locatie":"test","beschikbaartot":"2019-04-11 00:00:00","accepttot":"2019-04-11 16:43:00","status":"uitgezonden","cronstatus":"beschikbaaropgeven","opmerking":null,"created_at":"2019-04-21 14:39:54","updated_at":"2019-04-21 22:26:28"}]

Please sign in or create an account to participate in this conversation.