sql >> データベース >  >> RDS >> Mysql

Laravelでの出席の作成

    ビューを次のように変更できます

    <table class="table-responsive table-condensed table-striped table-hover table-bordered">
      <thead>
        <tr>
          <td>Salesman</td>
          <?php for($i = 1; $i <= $days_count; $i++){ ?>
          <td>
            <?php echo $i; ?>
          </td>
          <?php }?>
        </tr>
      </thead>
      <tbody>
        @forelse($final as $attend)
        <tr>
          <td>{{ $attend['name'] }}</td>
          <?php 
            for($i = 1; $i < $days_count; $i++){
              $make_date = date("Y-m")."-".$i;
              $set_attendance_for_day=false;
              $attendance_for_day ="-";
              foreach($attend['attendance'] as $att){
                if($att['date'] == $make_date){
                   $attendance_for_day = "P";
                } 
              } 
          ?>
          <td>
            <?php echo $attendance_for_day; ?>
          </td>
    
          <?php }?>
        </tr>
        @empty
        <tr>
          <td>No Salesman</td>
        </tr>
        @endforelse
      </tbody>
    </table>
    

    **コメントに基づいて更新

    <table class="table-responsive table-condensed table-striped table-hover table-bordered">
      <thead>
        <tr>
          <td>Salesman</td>
          <?php for($i = 1; $i <= $days_count; $i++){ ?>
          <td>
            <?php echo $i; ?>
          </td>
          <?php }?>
        </tr>
      </thead>
      <tbody>
        @forelse($final as $attend)
        <tr>
          <td>{{ $attend['name'] }}</td>
          <?php 
            for($i = 1; $i < $days_count; $i++){
              $make_date = date("Y-m")."-".$i;
              $set_attendance_for_day=false;
              $attendance_for_day ="-";
              foreach($attend['attendance'] as $att){
                if($att['date'] == $make_date){
                   $attendance_for_day = "P";
                } 
              } 
          ?>
          <td>
            <?php echo $attendance_for_day; ?>
            <?php if($i==20){ ?>
    
              ---------------------------------------------------
              <PLACE YOUR FORM HERE>
              ---------------------------------------------------
            <?php } ?>
          </td>
    
          <?php }?>
        </tr>
        @empty
        <tr>
          <td>No Salesman</td>
        </tr>
        @endforelse
      </tbody>
    </table>
    


    1. 予約システムの日付

    2. SQL Serverで先頭と末尾の空白を削除する方法– TRIM()

    3. MariaDBで1か月の日数を返す

    4. PHPの単語インデックス、パフォーマンス、および妥当な結果