• <bdo id='wQp1A'></bdo><ul id='wQp1A'></ul>
    1. <small id='wQp1A'></small><noframes id='wQp1A'>

      <i id='wQp1A'><tr id='wQp1A'><dt id='wQp1A'><q id='wQp1A'><span id='wQp1A'><b id='wQp1A'><form id='wQp1A'><ins id='wQp1A'></ins><ul id='wQp1A'></ul><sub id='wQp1A'></sub></form><legend id='wQp1A'></legend><bdo id='wQp1A'><pre id='wQp1A'><center id='wQp1A'></center></pre></bdo></b><th id='wQp1A'></th></span></q></dt></tr></i><div id='wQp1A'><tfoot id='wQp1A'></tfoot><dl id='wQp1A'><fieldset id='wQp1A'></fieldset></dl></div>

        <tfoot id='wQp1A'></tfoot>

        <legend id='wQp1A'><style id='wQp1A'><dir id='wQp1A'><q id='wQp1A'></q></dir></style></legend>

        数据仅在 Laravel 应用程序中插入最后一个数组

        时间:2023-09-22

        1. <legend id='RfOdX'><style id='RfOdX'><dir id='RfOdX'><q id='RfOdX'></q></dir></style></legend>

            <bdo id='RfOdX'></bdo><ul id='RfOdX'></ul>

            <i id='RfOdX'><tr id='RfOdX'><dt id='RfOdX'><q id='RfOdX'><span id='RfOdX'><b id='RfOdX'><form id='RfOdX'><ins id='RfOdX'></ins><ul id='RfOdX'></ul><sub id='RfOdX'></sub></form><legend id='RfOdX'></legend><bdo id='RfOdX'><pre id='RfOdX'><center id='RfOdX'></center></pre></bdo></b><th id='RfOdX'></th></span></q></dt></tr></i><div id='RfOdX'><tfoot id='RfOdX'></tfoot><dl id='RfOdX'><fieldset id='RfOdX'></fieldset></dl></div>
                <tbody id='RfOdX'></tbody>

              • <tfoot id='RfOdX'></tfoot>
                1. <small id='RfOdX'></small><noframes id='RfOdX'>

                  本文介绍了数据仅在 Laravel 应用程序中插入最后一个数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我有这个月的天数列表.但问题是当我插入或添加数据时,它只输入了列表中的最后一个数组或数据.例如,我添加 Jan-02-2019, 然后它会插入 Jan-31-2019.

                  控制器

                  公共函数insertSchedule(Request $request){$employeeTimeSet = 新时间表;$employeeTimeSet->employee_no = $request->input('hidEmployeeno');$employeeTimeSet->last_name = $request->input('hidEmployeeLast');$employeeTimeSet->first_name = $request->input('hidEmployeeFirst');$employeeTimeSet->date_today = $request->input('dateToday');$employeeTimeSet->time_in = $request->input('timeIn');$employeeTimeSet->time_out = $request->input('timeOut');$employeeTimeSet->save();}

                  这是视图和表单:

                  {!!Form::open(['action' => 'AdminEmployeeFilemController@insertSchedule', 'method' => 'POST']) !!}<div class="row"><div class="form-group col-md-12"><small>员工编号和姓名:</small><b><i>{{ $employee->employee_no }} : {{ $employee->last_name }}, {{ $employee->first_name }}</i></b><input type="hidden" name="hidEmployeeno" value='<?php echo $employee->employee_no ?>'><input type="hidden" name="hidEmployeeLast" value='<?php echo $employee->last_name ?>'><input type="hidden" name="hidEmployeeFirst" value='<?php echo $employee->first_name ?>'><小时>

                  @php$今天=今天();$dates = [];for($i=1; $i <$today->daysInMonth + 1; ++$i) {$dates[] = CarbonCarbon::createFromDate($today->year, $today->month, $i)->format('F-d-Y');}@endphp<table class="table"><头><tr><今天>今天</th><th>TIME IN</th><th>超时</th><th>Action</th></tr></thead>@foreach($dates 作为 $date)<tr><td><b>{{ $date }}</b></td><input type="hidden" name="dateToday" value="{{ $date }}"><td><input type="time" name="timeIn" class="form-control col-md-10"></td><td><input type="time" name="timeOut" class="form-control col-md-10"></td><td>{{Form::button('<i class="fa fa-clock">&nbsp;&nbsp;SET TIME</i>',['type' => 'submit','class' => 'btn btn-warning btn-sm', 'style'=>"display: inline-block;"])}}</td></tr>@endforeach</tbody>{!!表单::关闭() !!}

                  解决方案

                  我认为这是因为您构建 HTML 表单的方式.如果我正确理解了您的问题,以下内容应该可以解决问题:

                  @php$今天=今天();$dates = [];for($i=1; $i <$today->daysInMonth + 1; ++$i) {$dates[] = CarbonCarbon::createFromDate($today->year, $today->month, $i)->format('F-d-Y');}@endphp<div class="row"><div class="form-group col-md-12"><small>员工编号和姓名:</small><b><i>{{ $employee->employee_no }} : {{ $employee->last_name }}, {{ $employee->first_name }}</i></b><小时>

                  <table class="table"><头><tr><今天>今天</th><th>TIME IN</th><th>超时</th><th>Action</th></tr></thead>@foreach($dates 作为 $date){!!Form::open(['action' => 'AdminEmployeeFilemController@insertSchedule', 'method' => 'POST']) !!}<input type="hidden" name="hidEmployeeno" value="{{ $employee->employee_no }}"><input type="hidden" name="hidEmployeeLast" value="{{ $employee->last_name }}"><input type="hidden" name="hidEmployeeFirst" value="{{ $employee->first_name }}"><tr><td><b>{{ $date }}</b></td><input type="hidden" name="dateToday" value="{{ $date }}"><td><input type="time" name="timeIn" class="form-control col-md-10"></td><td><input type="time" name="timeOut" class="form-control col-md-10"></td><td>{{ Form::button('<i class="fa fa-clock">&nbsp;&nbsp;SET TIME</i>',['type' => 'submit','class' => 'btn btn-warning btn-sm', 'style'=>"display: inline-block;"]) }}</td></tr>{!!表单::关闭() !!}@endforeach</tbody>

                  I have a list of days for this month. But the problem is when I insert or add the data it only entered the last array or data from the list. For example, I add Jan-02-2019, and it will then insert Jan-31-2019.

                  Controller

                  public function insertSchedule(Request $request)
                  {
                      $employeeTimeSet = new Schedule;
                      $employeeTimeSet->employee_no = $request->input('hidEmployeeno');
                      $employeeTimeSet->last_name = $request->input('hidEmployeeLast');
                      $employeeTimeSet->first_name = $request->input('hidEmployeeFirst');
                      $employeeTimeSet->date_today = $request->input('dateToday');
                      $employeeTimeSet->time_in = $request->input('timeIn');
                      $employeeTimeSet->time_out = $request->input('timeOut');
                      $employeeTimeSet->save();
                  }
                  

                  Here are the view and form:

                  {!! Form::open(['action' => 'AdminEmployeeFilemController@insertSchedule', 'method' => 'POST']) !!}
                  <div class="row">
                      <div class="form-group col-md-12">
                          <small>Employee No. and Name:</small>
                          <b><i> {{ $employee->employee_no }} : {{ $employee->last_name }}, {{ $employee->first_name }}</i></b>
                          <input type="hidden" name="hidEmployeeno" value='<?php echo $employee->employee_no ?>'>
                          <input type="hidden" name="hidEmployeeLast" value='<?php echo $employee->last_name ?>'>
                          <input type="hidden" name="hidEmployeeFirst" value='<?php echo $employee->first_name ?>'>
                          <hr>
                      </div>
                  </div>
                  @php
                      $today = today(); 
                      $dates = []; 
                  
                      for($i=1; $i < $today->daysInMonth + 1; ++$i) {
                          $dates[] = CarbonCarbon::createFromDate($today->year, $today->month, $i)->format('F-d-Y');
                      }
                  @endphp
                  
                  <table class="table">
                      <thead>
                      <tr>
                          <th>DATE TODAY</th>
                          <th>TIME IN</th>
                          <th>TIME OUT</th>
                          <th>ACTION</th>
                      </tr>
                      </thead>
                      <tbody>
                      @foreach($dates as $date)
                          <tr>
                              <td><b>{{ $date }}</b></td>
                              <input type="hidden" name="dateToday" value="{{ $date }}">
                              <td><input type="time" name="timeIn" class="form-control col-md-10"></td>
                              <td><input type="time" name="timeOut" class="form-control col-md-10"></td>
                              <td>{{Form::button('<i class="fa fa-clock">&nbsp;&nbsp;SET TIME</i>',['type' => 'submit','class' => 'btn btn-warning btn-sm',  'style'=>"display: inline-block;"])}}</td>
                          </tr>
                      @endforeach
                      </tbody>
                  </table>
                  {!! Form::close() !!}
                  

                  解决方案

                  I think it's because of the way you structured your HTML form. If I understood your question correctly, the following should make it work:

                  @php
                      $today = today(); 
                      $dates = []; 
                      for($i=1; $i < $today->daysInMonth + 1; ++$i) {
                          $dates[] = CarbonCarbon::createFromDate($today->year, $today->month, $i)->format('F-d-Y');
                      }
                  @endphp
                  <div class="row">
                      <div class="form-group col-md-12">
                          <small>Employee No. and Name:</small>
                          <b><i> {{ $employee->employee_no }} : {{ $employee->last_name }}, {{ $employee->first_name }}</i></b>
                          <hr>
                      </div>
                  </div>
                  <table class="table">
                      <thead>
                      <tr>
                          <th>DATE TODAY</th>
                          <th>TIME IN</th>
                          <th>TIME OUT</th>
                          <th>ACTION</th>
                      </tr>
                      </thead>
                      <tbody>
                      @foreach($dates as $date)
                          {!! Form::open(['action' => 'AdminEmployeeFilemController@insertSchedule', 'method' => 'POST']) !!}
                              <input type="hidden" name="hidEmployeeno" value="{{ $employee->employee_no }}">
                              <input type="hidden" name="hidEmployeeLast" value="{{ $employee->last_name }}">
                              <input type="hidden" name="hidEmployeeFirst" value="{{ $employee->first_name }}">
                              <tr>
                                  <td><b>{{ $date }}</b></td>
                                  <input type="hidden" name="dateToday" value="{{ $date }}">
                                  <td><input type="time" name="timeIn" class="form-control col-md-10"></td>
                                  <td><input type="time" name="timeOut" class="form-control col-md-10"></td>
                                  <td>{{ Form::button('<i class="fa fa-clock">&nbsp;&nbsp;SET TIME</i>',['type' => 'submit','class' => 'btn btn-warning btn-sm',  'style'=>"display: inline-block;"]) }}</td>
                              </tr>
                          {!! Form::close() !!}
                      @endforeach
                      </tbody>
                  </table>
                  

                  这篇关于数据仅在 Laravel 应用程序中插入最后一个数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何在与 Laravel Eloquent 方法 WITH 连接的元素上使 下一篇:laravel ownsTo 给出 null

                  相关文章

                  最新文章

                  <tfoot id='AH61d'></tfoot>
                2. <small id='AH61d'></small><noframes id='AH61d'>

                    • <bdo id='AH61d'></bdo><ul id='AH61d'></ul>
                    <legend id='AH61d'><style id='AH61d'><dir id='AH61d'><q id='AH61d'></q></dir></style></legend>
                  1. <i id='AH61d'><tr id='AH61d'><dt id='AH61d'><q id='AH61d'><span id='AH61d'><b id='AH61d'><form id='AH61d'><ins id='AH61d'></ins><ul id='AH61d'></ul><sub id='AH61d'></sub></form><legend id='AH61d'></legend><bdo id='AH61d'><pre id='AH61d'><center id='AH61d'></center></pre></bdo></b><th id='AH61d'></th></span></q></dt></tr></i><div id='AH61d'><tfoot id='AH61d'></tfoot><dl id='AH61d'><fieldset id='AH61d'></fieldset></dl></div>