Laravel-将数据分组为一个数据

时间:2019-01-25 00:44:21

标签: sql laravel laravel-5 eloquent

如何将具有相同日期的这两个数据设为一个值?

enter image description here

如您所见,我有相同的日期,如何使它们成为一个值?

我的控制器

 public function showTime(Request $request, $id)
{
    $employee = Employeefm::find($id);


    $search = $request->get('search');
    $employeeSched = DB::table('schedules')->where('employee_no','like', '%'.$search.'%')->paginate(10);

    return view('admin.employeemaintenance.showTime',compact('employee','employeeSched'));
}

我的观点

      <tbody>

                    @foreach ($employeeSched as $setTime)
              <tr>

                 <td> {{Form::label('date_today', $setTime->date_today,['class'=>'form-control'])}}</td>
                 <td><input type="time" name="timeIn" class="form-control col-md-10" value='{{ $setTime->time_in }}'></td>
                 <td><p>12:00 PM - 1:00 PM</p></td>
                 <td><input type="time" name="timeOut" class="form-control col-md-10" value='{{ $setTime->time_out }}'></td>
                    <td>@php
                    $time1 = strtotime($setTime->time_in);
                    $time2 = strtotime($setTime->time_out);
                    $difference = round(abs($time2 - $time1) / 3600,2);
                    $total = $difference - 1;
                    echo '<b>' . $total . '</b>';
                 @endphp</td>


                <td>
                    @php
                    if ($total < 8) {
                        echo '<b>Under Time</b>';
                    } else if($total > 8) {
                        echo '<b>OT</b>';
                    } elseif ($total < 8.5 && $total == 8) {
                        echo '<b>In</b>';
                    }


                    @endphp
                </td>
              </tr>
              @endforeach



            </tbody>

我需要的输出是重复值将是一个值

0 个答案:

没有答案