Getting Http 500 error in laravel after a while loop

i’m trynig to display the disponibility of a user , with start time and end time , when i’m trying to add the Break time between the start and the end time with the while loop , this error appear: HTTP 500 error .
This is The controller :

public function rdv( $ID)
{
     $model=doc::findOrFail($ID);
     $ReturnArray = array ();// Define output
     $StartTime    = strtotime ($model->Lun_mat_de[0]) ; //Get Timestamp
     $EndTime      = strtotime ($model->Lun_apres_a[1]); //Get Timestamp
     $break_start = strtotime ($model->Lun_mat_de[1]) ; // break start
     $break_end   = strtotime ($model->Lun_apres_a[0]);// break end
     $breakConditions = ($StartTime <= $break_start) || ($EndTime >=$break_end) ;
     $duration = '60';
 
    $AddMins  = $duration * 60;

          do //Run loop
        {
            $ReturnArray[] = date("G:i", $StartTime );
            $StartTime  += $AddMins; //Endtime check
        }  
        while ($breakConditions) ;

        return view ('/rendezvous')->with([
            'go'=> $model, 
            'disponibility'=>$ReturnArray, 
        ]); 
}



and this is the view 

<div class="card-header">
<img src="{{asset ('assets/img/uploads/'.$go->Photo)}}" alt="" class="profile-img">

<div class="col-6">
<h2> <strong> Dr. {{$go -> Nom}} {{$go -> Prénom}} </strong> </h2>
<h3> {{$go-> Spécialité}} </h3>
<h6 class="city"> Adresse cabinet : {{$go->Adresse_Cabinet}} </h6>
<h6 class="city"> Ville : {{$go-> Ville}} </h6>
<p class="full-name"> Qualification professionnelle :</p>
<h6 class="city"> Spécialité: {{$go-> Spécialité}} </h6>
<h6 class="city"> Diplome : {{$go-> Diplome}} </h6>
<p class="full-name"> Informations pratiques :</p>
<h6 class="city"> Mode de réglement : {{$go-> mr}} </h6>
<h6 class="city"> Assurance maladie : {{$go-> ass_m}} </h6>
 </div>
<div class="col-6">
<p class="full-name"> Les horaires: </p>
<div class="div1" ></div>
@foreach($jaja as $ja)
<button class="btn btn-info"> {{$ja}} </button> </br>
@endforeach

$jaja doesn’t seem to be defined anywhere. Did you mean $go->jaja ?

Doesn’t $breakConditions resolve into a simple true/false boolean in its declaration (in this case true) and so the cause of your HTTP 500 error is an infinite loop?

1 Like