數據僅在 Laravel 應用程序中插入最后一個數組
2023-09-22
php問題
html5模板網
Data inserts the last array only in a Laravel app(數據僅在 Laravel 應用程序中插入最后一個數組)
本文介紹了數據僅在 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"> 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"> 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"> 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"> SET TIME</i>',['type' => 'submit','class' => 'btn btn-warning btn-sm', 'style'=>"display: inline-block;"]) }}</td>
</tr>
{!! Form::close() !!}
@endforeach
</tbody>
</table>
這篇關于數據僅在 Laravel 應用程序中插入最后一個數組的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!
相關文檔推薦
MySQLi prepared statement amp; foreach loop(MySQLi準備好的語句amp;foreach 循環)
Is mysqli_insert_id() gets record from whole server or from same user?(mysqli_insert_id() 是從整個服務器還是從同一用戶獲取記錄?)
PHP MySQLi doesn#39;t recognize login info(PHP MySQLi 無法識別登錄信息)
mysqli_select_db() expects exactly 2 parameters(mysqli_select_db() 需要 2 個參數)
Php mysql pdo query: fill up variable with query result(Php mysql pdo 查詢:用查詢結果填充變量)
MySQLI 28000/1045 Access denied for user #39;root#39;@#39;localhost#39;(MySQLI 28000/1045 用戶“root@“localhost的訪問被拒絕)
主站蜘蛛池模板:
气动调节阀,电动调节阀,自力式压力调节阀,切断阀「厂家」-浙江利沃夫自控阀门
|
滑石粉,滑石粉厂家,超细滑石粉-莱州圣凯滑石有限公司
|
熔体泵_熔体出料泵_高温熔体泵-郑州海科熔体泵有限公司
|
河北凯普威医疗器材有限公司,高档轮椅系列,推车系列,座厕椅系列,协步椅系列,拐扙系列,卫浴系列
|
深圳货架厂家_金丽声精品货架_广东金丽声展示设备有限公司官网
|
济南ISO9000认证咨询代理公司,ISO9001认证,CMA实验室认证,ISO/TS16949认证,服务体系认证,资产管理体系认证,SC食品生产许可证- 济南创远企业管理咨询有限公司
郑州电线电缆厂家-防火|低压|低烟无卤电缆-河南明星电缆
|
升降机-高空作业车租赁-蜘蛛车-曲臂式伸缩臂剪叉式液压升降平台-脚手架-【普雷斯特公司厂家】
|
地脚螺栓_材质_标准-永年县德联地脚螺栓厂家 |
温控器生产厂家-提供温度开关/热保护器定制与批发-惠州市华恺威电子科技有限公司
|
天津拓展_天津团建_天津趣味运动会_天津活动策划公司-天津华天拓展培训中心
|
破碎机_上海破碎机_破碎机设备_破碎机厂家-上海山卓重工机械有限公司
|
餐饮小吃技术培训-火锅串串香培训「何小胖培训」_成都点石成金[官网]
|
蓄电池回收,ups电池后备电源回收,铅酸蓄电池回收,机房电源回收-广州益夫铅酸电池回收公司
|
河北凯普威医疗器材有限公司,高档轮椅系列,推车系列,座厕椅系列,协步椅系列,拐扙系列,卫浴系列
|
湖南自考_湖南自学考试
|
超声波焊接机,振动摩擦焊接机,激光塑料焊接机,超声波焊接模具工装-德召尼克(常州)焊接科技有限公司
|
上海平衡机-单面卧式动平衡机-万向节动平衡机-圈带动平衡机厂家-上海申岢动平衡机制造有限公司
|
高精度电阻回路测试仪-回路直流电阻测试仪-武汉特高压电力科技有限公司
|
工装定制/做厂家/公司_工装订做/制价格/费用-北京圣达信工装
|
热闷罐-高温罐-钢渣热闷罐-山东鑫泰鑫智能热闷罐厂家
|
广州市哲铭油墨涂料有限公司,水性漆生产研发基地
|
六维力传感器_六分量力传感器_模腔压力传感器-南京数智微传感科技有限公司
|
电线电缆厂家|沈阳电缆厂|电线厂|沈阳英联塑力线缆有限公司
|
led太阳能路灯厂家价格_风光互补庭院灯_农村市政工程路灯-中山华可路灯品牌
|
铝合金重力铸造_铝合金翻砂铸造_铝铸件厂家-东莞市铝得旺五金制品有限公司
|
深圳宣传片制作_产品视频制作_深圳3D动画制作公司_深圳短视频拍摄-深圳市西典映画传媒有限公司
|
屏蔽泵厂家,化工屏蔽泵_维修-淄博泵业 |
环境模拟实验室_液体-气体控温机_气体控温箱_无锡双润冷却科技有限公司
|
背压阀|减压器|不锈钢减压器|减压阀|卫生级背压阀|单向阀|背压阀厂家-上海沃原自控阀门有限公司
本安接线盒-本安电路用接线盒-本安分线盒-矿用电话接线盒-JHH生产厂家-宁波龙亿电子科技有限公司
|
颚式破碎机,圆锥破碎机,制砂机-新乡市德诚机电制造有限公司
|
贴片电容-贴片电阻-二三极管-国巨|三星|风华贴片电容代理商-深圳伟哲电子
|
防爆暖风机_防爆电暖器_防爆电暖风机_防爆电热油汀_南阳市中通智能科技集团有限公司
|
耐高温电缆厂家-远洋高温电缆 |
涡轮流量计_LWGY智能气体液体电池供电计量表-金湖凯铭仪表有限公司
|
医学动画公司-制作3d医学动画视频-医疗医学演示动画制作-医学三维动画制作公司
|
氧化铝球_高铝球_氧化铝研磨球-淄博誉洁陶瓷新材料有限公司
|
流量检测仪-气密性检测装置-密封性试验仪-东莞市奥图自动化科技有限公司
|
京马网,京马建站,网站定制,营销型网站建设,东莞建站,东莞网站建设-首页-京马网
|
超声波焊接机,振动摩擦焊接机,激光塑料焊接机,超声波焊接模具工装-德召尼克(常州)焊接科技有限公司
|
天津中都白癜风医院_天津白癜风医院_天津治疗白癜风
|
丝杆升降机-不锈钢丝杆升降机-非标定制丝杆升降机厂家-山东鑫光减速机有限公司
|