我的HTML代码
<div class="businessHours-input">
<table>
<tr>
<th>Week Days</th>
<th>Opening Time</th>
<th>Closing Time</th>
<th>Open 24 hours</th>
<th>Close</th>
</tr>
<tr>
<td>
<div class="per-input per-businessHour">
<input type="text" name="weekday[1]" href="1" id="weekday1" class="form-control" value="Saturday">
</div>
</td>
<td>
<div class="per-input per-businessHour">
<select name="opening_time[1]" class="opening_time" href="1" id="opening_time1">
<option value="">Choose</option>
@if ($range = range(strtotime('00:00'),strtotime('23:59'),30*60))
@foreach ($range as $time)
<option value="{{ date('h:i A',$time) }}">{{ date('h:i A',$time) }}</option>
@endforeach
@endif
</select>
<span value="1" class="editOpening">Edit</span>
</div>
</td>
<td>
<div class="per-input per-businessHour">
<select name="closing_time[1]" class="closing_time" href="1" id="closing_time1">
<option value="">Choose</option>
@if ($range = range(strtotime('00:00'),strtotime('23:59'),30*60))
@foreach ($range as $time)
<option value="{{ date('h:i A',$time) }}">{{ date('h:i A',$time) }}</option>
@endforeach
@endif
</select>
<span value="1" class="editClosing">Edit</span>
</div>
</td>
<td>
<div class="per-input per-businessHour">
<label for="always1"><input type="checkbox" name="always[1]" value="always" class="alwaysOpen" href="1" id="always1"> 24Hours</label>
</div>
</td>
<td>
<div class="per-input per-businessHour">
<label for="close1"><input type="checkbox" name="close[1]" class="closeBiz" value="close" href="1" id="close1"> Close</label>
</div>
</td>
</tr>
<tr>
<td>
<div class="per-input per-businessHour">
<input type="text" name="weekday[2]" href="2" id="weekday2" class="form-control" value="Sunday">
</div>
</td>
<td>
<div class="per-input per-businessHour">
<select name="opening_time[2]" class="opening_time" href="2" id="opening_time2">
<option value="">Choose</option>
@if ($range = range(strtotime('00:00'),strtotime('23:59'),30*60))
@foreach ($range as $time)
<option value="{{ date('h:i A',$time) }}">{{ date('h:i A',$time) }}</option>
@endforeach
@endif
</select>
<span value="2" class="editOpening">Edit</span>
</div>
</td>
<td>
<div class="per-input per-businessHour">
<select name="closing_time[2]" class="closing_time" href="2" id="closing_time2">
<option value="">Choose</option>
@if ($range = range(strtotime('00:00'),strtotime('23:59'),30*60))
@foreach ($range as $time)
<option value="{{ date('h:i A',$time) }}">{{ date('h:i A',$time) }}</option>
@endforeach
@endif
</select>
<span value="2" class="editClosing">Edit</span>
</div>
</td>
<td>
<div class="per-input per-businessHour">
<label for="always2"><input type="checkbox" name="always[2]" value="always" class="alwaysOpen" href="2" id="always2"> 24Hours</label>
</div>
</td>
<td>
<div class="per-input per-businessHour">
<label for="close2"><input type="checkbox" name="close[2]" class="closeBiz" value="close" href="2" id="close2"> Close</label>
</div>
</td>
</tr>
<tr>
<td>
<div class="per-input per-businessHour">
<input type="text" name="weekday[3]" href="3" id="weekday3" class="form-control" value="Monday">
</div>
</td>
<td>
<div class="per-input per-businessHour">
<select name="opening_time[3]" class="opening_time" href="3" id="opening_time3">
<option value="">Choose</option>
@if ($range = range(strtotime('00:00'),strtotime('23:59'),30*60))
@foreach ($range as $time)
<option value="{{ date('h:i A',$time) }}">{{ date('h:i A',$time) }}</option>
@endforeach
@endif
</select>
<span value="3" class="editOpening">Edit</span>
</div>
</td>
<td>
<div class="per-input per-businessHour">
<select name="closing_time[3]" class="closing_time" href="3" id="closing_time3">
<option value="">Choose</option>
@if ($range = range(strtotime('00:00'),strtotime('23:59'),30*60))
@foreach ($range as $time)
<option value="{{ date('h:i A',$time) }}">{{ date('h:i A',$time) }}</option>
@endforeach
@endif
</select>
<span value="3" class="editClosing">Edit</span>
</div>
</td>
<td>
<div class="per-input per-businessHour">
<label for="always3"><input type="checkbox" name="always[3]" value="always" class="alwaysOpen" href="3" id="always3"> 24Hours</label>
</div>
</td>
<td>
<div class="per-input per-businessHour">
<label for="close3"><input type="checkbox" name="close[3]" class="closeBiz" value="close" href="3" id="close3"> Close</label>
</div>
</td>
</tr>
<tr>
<td>
<div class="per-input per-businessHour">
<input type="text" name="weekday[4]" href="4" id="weekday4" class="form-control" value="Tuesday">
</div>
</td>
<td>
<div class="per-input per-businessHour">
<select name="opening_time[4]" class="opening_time" id="opening_time4">
<option value="">Choose</option>
@if ($range = range(strtotime('00:00'),strtotime('23:59'),30*60))
@foreach ($range as $time)
<option value="{{ date('h:i A',$time) }}">{{ date('h:i A',$time) }}</option>
@endforeach
@endif
</select>
<span value="4" class="editOpening">Edit</span>
</div>
</td>
<td>
<div class="per-input per-businessHour">
<select name="closing_time[4]" class="closing_time" href="4" id="closing_time4">
<option value="">Choose</option>
@if ($range = range(strtotime('00:00'),strtotime('23:59'),30*60))
@foreach ($range as $time)
<option value="{{ date('h:i A',$time) }}">{{ date('h:i A',$time) }}</option>
@endforeach
@endif
</select>
<span value="4" class="editClosing">Edit</span>
</div>
</td>
<td>
<div class="per-input per-businessHour">
<label for="always4"><input type="checkbox" name="always[4]" value="always" class="alwaysOpen" href="4" id="always4"> 24Hours</label>
</div>
</td>
<td>
<div class="per-input per-businessHour">
<label for="close4"><input type="checkbox" name="close[4]" class="closeBiz" value="close" href="4" id="close4"> Close</label>
</div>
</td>
</tr>
<tr>
<td>
<div class="per-input per-businessHour">
<input type="text" name="weekday[5]" href="5" id="weekday5" class="form-control" value="Wednesday">
</div>
</td>
<td>
<div class="per-input per-businessHour">
<select name="opening_time[5]" class="opening_time" href="5" id="opening_time5">
<option value="">Choose</option>
@if ($range = range(strtotime('00:00'),strtotime('23:59'),30*60))
@foreach ($range as $time)
<option value="{{ date('h:i A',$time) }}">{{ date('h:i A',$time) }}</option>
@endforeach
@endif
</select>
<span value="5" class="editOpening">Edit</span>
</div>
</td>
<td>
<div class="per-input per-businessHour">
<select name="closing_time[5]" class="closing_time" href="5" id="closing_time5">
<option value="">Choose</option>
@if ($range = range(strtotime('00:00'),strtotime('23:59'),30*60))
@foreach ($range as $time)
<option value="{{ date('h:i A',$time) }}">{{ date('h:i A',$time) }}</option>
@endforeach
@endif
</select>
<span value="5" class="editClosing">Edit</span>
</div>
</td>
<td>
<div class="per-input per-businessHour">
<label for="always5"><input type="checkbox" name="always[5]" value="always" class="alwaysOpen" href="5" id="always5"> 24Hours</label>
</div>
</td>
<td>
<div class="per-input per-businessHour">
<label for="close5"><input type="checkbox" name="close[5]" class="closeBiz" value="close" href="5" id="close5"> Close</label>
</div>
</td>
</tr>
<tr>
<td>
<div class="per-input per-businessHour">
<input type="text" name="weekday[6]" href="6" id="weekday6" class="form-control" value="Thursday">
</div>
</td>
<td>
<div class="per-input per-businessHour">
<select name="opening_time[6]" class="opening_time" href="6" id="opening_time6">
<option value="">Choose</option>
@if ($range = range(strtotime('00:00'),strtotime('23:59'),30*60))
@foreach ($range as $time)
<option value="{{ date('h:i A',$time) }}">{{ date('h:i A',$time) }}</option>
@endforeach
@endif
</select>
<span value="6" class="editOpening">Edit</span>
</div>
</td>
<td>
<div class="per-input per-businessHour">
<select name="closing_time[6]" class="closing_time" href="6" id="closing_time6">
<option value="">Choose</option>
@if ($range = range(strtotime('00:00'),strtotime('23:59'),30*60))
@foreach ($range as $time)
<option value="{{ date('h:i A',$time) }}">{{ date('h:i A',$time) }}</option>
@endforeach
@endif
</select>
<span value="6" class="editClosing">Edit</span>
</div>
</td>
<td>
<div class="per-input per-businessHour">
<label for="always6"><input type="checkbox" name="always[6]" value="always" class="alwaysOpen" href="6" id="always6"> 24Hours</label>
</div>
</td>
<td>
<div class="per-input per-businessHour">
<label for="close6"><input type="checkbox" name="close[6]" class="closeBiz" value="close" href="6" id="close6"> Close</label>
</div>
</td>
</tr>
<tr>
<td>
<div class="per-input per-businessHour">
<input type="text" name="weekday[7]" href="7" id="weekday7" class="form-control" value="Friday">
</div>
</td>
<td>
<div class="per-input per-businessHour">
<select name="opening_time[7]" class="opening_time" href="7" id="opening_time7">
<option value="">Choose</option>
@if ($range = range(strtotime('00:00'),strtotime('23:59'),30*60))
@foreach ($range as $time)
<option value="{{ date('h:i A',$time) }}">{{ date('h:i A',$time) }}</option>
@endforeach
@endif
</select>
<span value="7" class="editOpening">Edit</span>
</div>
</td>
<td>
<div class="per-input per-businessHour" id="closebizHour7">
<select name="closing_time[7]" class="closing_time" href="7" id="closing_time7">
<option value="">Choose</option>
@if ($range = range(strtotime('00:00'),strtotime('23:59'),30*60))
@foreach ($range as $time)
<option value="{{ date('h:i A',$time) }}">{{ date('h:i A',$time) }}</option>
@endforeach
@endif
</select>
<span value="7" class="editClosing">Edit</span>
</div>
</td>
<td>
<div class="per-input per-businessHour">
<label for="always7"><input type="checkbox" name="always[7]" value="always" class="alwaysOpen" href="7" id="always7"> 24Hours</label>
</div>
</td>
<td>
<div class="per-input per-businessHour">
<label for="close7"><input type="checkbox" name="close[7]" class="closeBiz" value="close" href="7" id="close7"> Close</label>
</div>
</td>
</tr>
</table>
</div>
我要上传的laravel代码
foreach ($request->weekday as $key => $weekday) {
$proBusiness = new ProBusinessHour;
$proBusiness->pro_listing_id = $proListing->id;
$proBusiness->weekday = $weekday;
if (($request->opening_time[$key] && $request->closing_time[$key]) == null) {
if ($request->close[$key] == 'close') {
$proBusiness->close = 1;
} else {
if ($request->always[$key] == 'always') {
$proBusiness->always = 1;
}
}
} else {
if (($request->opening_time[$key] && $request->closing_time[$key]) == null && $request->always[$key] == 'always') {
$proBusiness->always = 1;
} else {
$proBusiness->opening_time = $request->opening_time[$key];
$proBusiness->closing_time = $request->closing_time[$key];
}
}
$proBusiness->save();
}
问题描述如下:
有7天。如果有一天,没有开放时间和关闭时间,并且具有接近价值或始终有价值。在这种情况下,它需要上传关闭状态或始终显示状态
如果除某天以外的所有时间总具有价值,并且具有接近的价值。在这种情况下,它需要全天都上载始终状态,除非具有关闭值的那一天都上载,并在该天上载关闭状态
***有时它会返回
"Undefined offset: 1", exception: "ErrorException"
如何解决此问题?我无法解决这个问题,laravel代码中是否有任何错误?谁能帮我解决这个问题!