jeudi 24 janvier 2019

Laravel - Group data into one data

how can I make this two data which has the same date into a one value?

enter image description here

As you can see I have the same date, how can I make them into one value?

my Controller

 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'));
}

my View

      <tbody>

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

                 <td> </td>
                 <td><input type="time" name="timeIn" class="form-control col-md-10" value=''></td>
                 <td><p>12:00 PM - 1:00 PM</p></td>
                 <td><input type="time" name="timeOut" class="form-control col-md-10" value=''></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>

the output I need is thos duplicate value will be a one value



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire