mercredi 11 avril 2018

Laravel Data Structure By Hours

Im using laravel 5.6 for my website, and i want the output to be like this . http://prntscr.com/j3p8rg and my database table structure like this http://prntscr.com/j3tqhx . I dont get the exact code. or can somebody teach me exact way to do what i want to do. thanks, this is my code for query. $datelogin = Carbon::Now('Asia/Manila')->toDateString(); $result = Userlog ::join('status', 'userlogs.slack_id', '=', 'status.slack_id') ->select('userlogs.slack_id', 'status.status_message','status.date_login','userlogs.first_name','status.time_status') ->where('userlogs.date_login', '=', $datelogin) ->getQuery() // Optional: downgrade to non-eloquent builder so we don't build invalid User objects. ->get();

this is my code to my table

<table id="example1" class="table table-bordered table-striped">
            <thead>
            <tr>
              <th>Hours</th>
              <th>Franklin</th>
              <th>Joemar</th>
              <th>Edmondo</th>
              <th>Eric</th>
              <th>Jovel</th>
              <th>Anna</th>
              <th>Crisnil</th>
            </tr>
            </thead>
            <tbody>
                    <tr>
                        <th>4pm</th>
                        @foreach($result as $results)
                            <td>
                                <?php 

                                    $time = Carbon::createFromTime(16,00,00, 'Asia/Manila')->format('g:i A');
                                    $time1 = Carbon::createFromTime(17,00,00, 'Asia/Manila')->format('g:i A');
                                    $times = $results->time_status;
                                    $id = $results->slack_id;
                                    if($times >= $time && $times <= $time1 && $id == 'U9NPQDMH9'){
                                        echo $results->status_message;
                                    }
                                ?>
                            </td>
                        @endforeach
                    </tr>
                    <tr>
                        <th>5pm</th>
                        @foreach($result as $results)
                            <td>
                                <?php 

                                    $time = Carbon::createFromTime(17,00,00, 'Asia/Manila')->format('g:i A');
                                    $time1 = Carbon::createFromTime(18,00,00, 'Asia/Manila')->format('g:i A');
                                    $times = $results->time_status;
                                    $id = $results->slack_id;
                                    if($times >= $time && $times <= $time1 && $id == 'U9NPQDMH9'){
                                        echo $results->status_message;
                                    }
                                ?>
                            </td>
                        @endforeach
                    </tr>
                    <tr>
                        <th>6pm</th>
                        @foreach($result as $results)
                            <td>
                                <?php 

                                    $time = Carbon::createFromTime(18,00,00, 'Asia/Manila')->format('g:i A');
                                    $time1 = Carbon::createFromTime(19,00,00, 'Asia/Manila')->format('g:i A');
                                    $times = $results->time_status;
                                    $id = $results->slack_id;
                                    if($times >= $time && $times <= $time1 && $id == 'U9NPQDMH9'){
                                        echo $results->status_message;
                                    }
                                ?>
                            </td>
                        @endforeach
                    </tr>
                    <tr>
                        <th>7pm</th>
                    </tr>
                    <tr>
                        <th>8pm</th>
                    </tr>
                    <tr>
                        <th>9pm</th>
                    </tr>
                    <tr>
                        <th>10pm</th>
                    </tr>
                    <tr>
                        <th>11pm</th>
                    </tr>
                    <tr>
                        <th>12pm</th>
                    </tr>

            </tbody>
            <tfoot>
            <tr>
              <th>Hours</th>
              <th>Franklin</th>
              <th>Joemar</th>
              <th>Edmondo</th>
              <th>Eric</th>
              <th>Jovel</th>
              <th>Anna</th>
              <th>Crisnil</th>
            </tr>
            </tfoot>
          </table>

Somebody help me to get out this problem? thanks in advance.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire