您好,我在尝试运行代码时遇到了一些错误。 这是我的laravel刀片。它显示未定义的偏移量:此刀片中为2。这是指数组还是css的偏移量?我不知道它意味着什么。请帮忙。非常感谢!
<h5 class="page-header"></h5>
<div class="panel panel-success">
@if($errors->any())
<div class="alert alert-danger">
@foreach($errors->all() as $error)
<div>{{ $error }}</div>
@endforeach
</div>
@endif
<div class="panel-heading">
<h4 class="panel-title">Add Transaction</h4>
</div>
<div class="panel-body">
<input type="hidden" name="DriverCommission" id="DriverCommission" value="<?php echo $TicketData[0]->amount;?>">
<input type="hidden" name="EntranceFee" id="EntranceFee" value="<?php echo $TicketData[1]->amount;?>">
<input type="hidden" name="Complimentary" id="Complimentary" value="<?php echo $TicketData[2]->amount;?>">
<div class="form-group">
{{ Form::label('Current Entrance Fee:') }}
{{ Form::text('P',null,['class' => 'form-control', 'placeholder' => '60', 'id' => 'EntranceFee','required' , 'readonly']) }}
</div>
<div class="form-group">
{{ Form::label('No. of Guest(s) :') }}
{{ Form::text('particular',null,['class' => 'form-control', 'placeholder' => '', 'id' => 'particular' ,'required']) }}
</div>
<div class="form-group">
{{ Form::label('Amount of Ticket :') }}
{{ Form::text('P',null,['class' => 'form-control', 'placeholder' => '', 'id' => 'ticket_amount','required' , 'readonly']) }}
</div>
<div class="form-group">
{{ Form::checkbox('agree', 1, null, ['class' => 'field' , 'id' => 'WithDriver']) }}
{{ Form::label('w/ Tourist Driver') }}
</div>
<div class="form-group">
{{ Form::checkbox('agree', 1, null, ['class' => 'field' , 'id' => 'Complimentary']) }}
{{ Form::label('Complimentary (P0.00)') }}
</div>
<div class="center"><button type="button" id="btnContinue" {{-- data-toggle="modal" data-target="#myModal" --}} class="btn btn-success">Continue</button></div>
</div>
</div>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="contactLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="panel panel-success">
<div class="panel-heading">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="panel-title">Transaction Details</h4>
</div>
<div class="panel-body">
{{ Form::open((['url' => 'ticket/transact'])) }}
<input type="hidden" name="DriverCommission" id="DriverCommission" value="<?php echo $TicketData[0]->amount;?>">
<input type="hidden" name="EntranceFee" id="EntranceFee" value="<?php echo $TicketData[1]->amount;?>">
<input type="hidden" name="Complimentary" id="Complimentary" value="<?php echo $TicketData[2]->amount;?>">
<input type="hidden" name="is_driver" id="is_driver" value="0">
<input type="hidden" name="ticket_min_range" id="ticket_min_range" value="">
<input type="hidden" name="ticket_max_range" id="ticket_max_range" value="">
<div class="form-group">
<h6 class="right-align" id="ticketNumberText">Ticket Number(s):</h6>
</div>
<div class="form-group">
{{ Form::label('No. of Ticket(s) :') }}
{{ Form::text('no_of_tickets',null,['class' => 'form-control', 'placeholder' => '' , 'id'=>"modal_tickets" ,'required' ,'readonly']) }}
</div>
<div class="form-group">
{{ Form::label('Total Price :') }}
{{ Form::text('total_price',null,['id'=>"modal_totalprice" ,'class' => 'form-control', 'placeholder' => '','required' ,'readonly']) }}
</div>
<div class="form-group">
{{ Form::label('Amount Tendered :') }}
{{ Form::text('amount_tendered',null,['id'=>"modal_tendered" ,'class' => 'form-control', 'placeholder' => '','required']) }}
</div>
<div class="form-group">
{{ Form::label('Change :') }}
{{ Form::text('amount_change',null,['id'=>"modal_change" ,'class' => 'form-control', 'placeholder' => '','required' , 'readonly']) }}
</div>
<div class="form-group">
{{ Form::submit('Save Transaction',['class' => 'btn btn-success']) }}
</div>
{{ Form::close() }}
</div>
</div>
</div>
</div>
<script type="text/javascript">
$(document).on("keyup" , "#particular" , function (){
CalulateAmount();
});
$(document).on("change" , "#WithDriver" , function (){
if(($('#WithDriver').is(":checked"))){
$("#is_driver").val(1);
}
else{
$("#is_driver").val(0);
}
});
function CalulateAmount(){
var NumberOfTickets = $("#particular").val();
var EntranceFee = $("#EntranceFee").val();
var DriverCommision = $("#DriverCommission").val();
var Amount = (NumberOfTickets*EntranceFee);
$("#modal_tickets").val(NumberOfTickets);
$("#modal_totalprice").val(Amount);
$("#ticket_amount").val(Amount);
}
$(document).on("keyup" , "#modal_tendered" , function (){
var TotalPrice = $("#modal_totalprice").val();
var Tendered = this.value;
var Change = (Tendered - TotalPrice) ;
$("#modal_change").val(Change);
});
$(document).on("click" , ".btnReset" , function (){
$("#modal_tendered").val("");
$("#modal_change").val("");
});
$(document).on("click" , "#btnContinue" , function (){
$.ajax({
url: '{{ URL::to("admin/CheckLastticketUsed") }}',
type: 'GET',
data : { total_tickets : $("#particular").val() },
dataType: "json",
success: function(data, textStatus, jqXHR){
if(data.status == true){
console.log(data.ticket_ranges);
$("#ticket_min_range").val(data.start_range);
$("#ticket_max_range").val(data.end_range);
$("#ticketNumberText").html("Ticket Number(s):"+ data.ticket_ranges);
}
else{
}
};
error: function(jqXHR, textStatus, errorThrown){
}
});
$('#myModal').modal('show');
});
</script>
@stop
HEre是我的职责:
class TPController extends Controller
{
public function index()
{
return view('tp.tpIndex');
}
public function transactTicket()
{
$GetTicketData = Chap_ticket::where('id' ,4)->Orwhere('id' ,5)->Orwhere('id' ,8)->get();
return view('tp.transactTicket')->with('TicketData', $GetTicketData);
}
public function submitTicket(Request $request){
//return $request->all();
$min = $request->ticket_min_range;
$max = $request->ticket_max_range;
// return "min: $min max: $max";
$ticket_numbers = array();
for ($i=$min; $i <= $max; $i++) {
Entrance_ticket::where('ticket_number', $i)
->update(['is_use' => 1]);
}
die();
// return view('tp.transactTicket')->with('TicketData', $GetTicketData);
}
答案 0 :(得分:1)
尝试在视图中对这些行进行评论:
<input type="hidden" name="Complimentary" id="Complimentary" value="<?php echo $TicketData[2]->amount;?>">
您遇到的错误与访问$TicketData
有关,您在代码中输入了两行我相信如果您发表评论,您的观点就会正常运行。