在 laravel 中时出现 Http 500 错误

Getting Http 500 error after while in laravel

我正在尝试显示用户的责任,开始时间和结束时间,当我试图在开始时间和结束时间之间添加休息时间时,while 循环出现此错误: HTTP 500 错误。这是控制器:

public 函数 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, 
        ]); 
}

这是视图:

<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

你的循环是错误的。 $breakConditions 不会像您假设的那样在每次迭代时都重新评估 - 此时它已经知道 恒定值 并且对 $StartDate 等的任何更改都是无关紧要的。你需要改变

do {
.... 
} while ($breakConditions);

do {
... 
} while (($StartTime <= $break_start) || ($EndTime >=$break_end));

PS:您还应该考虑遵循一些编码风格,包括。变量命名方案,因为您目前拥有的是 mess style.