lundi 10 octobre 2016

laravel blade for and foreach with if loop maximum time

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

if has $time foreach = for loop $i is output <div>O</div>, else is output<div>X</div>

but my code is trouble... loop 35 time.

I want loop total maximum time of 7

example : X X X O X X X

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