lundi 10 octobre 2016

laravel blade for and foreach with if loop

I want to for loop 7,and foeach $time to blade.

if foeach $time = for loop $i is output <div>O</div>

else is output <div>X</div>

total is loop 7, but my code is trouble...

How can I do, Please help me, thanks~

blade.php

@for ($i = 0; $i < 7; $i++)
@foreach($time as $value)

@if($value->time == $i)
  <div>O</div>
@else
  <div>X</div>   
@endif

@endforeach
@endfor

Controller

public function interview()
{
    $time = Interview_time::where('bsinformations_id',5)->get();
    return view('bs_sidebar.interview_time', [
        'time' => $time
    ]);
}

Aucun commentaire:

Enregistrer un commentaire