I've made a form for searching the bill number. When the bill is found in database table, the data should be shown in labels. How can I do that? Then the user press the button to pay for the billed amount.
view block
<form class="form-horizontal" method="POST" action="" enctype="multipart/form-data">
<div class="row" style="padding-left: 1%;">
<div class="col-md-4">
<div class="form-group">
<label>Bill Number</label><span class="required">*</span>
<input type="text" maxlength="15" required="required" autofocus="autofocus" autocomplete="off" name="NBillNumber" class="form-control"/>
</div>
</div>
<div class="col-md-4">
<div class="form-group"></div>
<div class="form-group" style="padding-left: 5%;">
<button type="submit" class="btn btn-primary">Search</button>
</div>
</div>
</div>
</form>
<div class="row" style="padding-left: 1%;">
<div class="col-md-4">
<div class="form-group">
<label>Book ID</label>
<output name="NBookID" class="form-control" aria-readonly="true"/>
</div>
<div class="form-group">
<label>Billed Date</label>
<output name="NBilledDate" class="form-control" aria-readonly="true"/>
</div>
</div>
<div class="col-md-4" style="padding-left: 3%;">
<div class="form-group">
<label>Billed Number</label>
<output name="NBilledNumber" class="form-control" aria-readonly="true"/>
</div>
<div class="form-group">
<label>Quantity</label>
<output name="NBilledQuantity" class="form-control" aria-readonly="true"/>
</div>
</div>
<div class="col-md-4"style="padding-left: 3%;">
<div class="form-group">
<label>Price</label>
<output name="NBilledPrice" class="form-control" aria-readonly="true"/>
</div>
<div class="form-group">
<label>Remarks</label>
<output name="NBilledRemarks" class="form-control" aria-readonly="true"/>
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary">PAY</button>
</div>
</div>
</div>
OrderedBookController code block
public function searchBill()
{
return view ( 'pages.payBill');
}
public function billPay(Request $request)
{
$billNum = $request->input('NBillNumber');
if($billNum != ""){
$billsrch = OrderedBook::where ( 'BilledNum', $billNum )->get ();
if (count ( $billsrch ) > 0)
{
return response()->json($billsrch);
return view('pages.payBill', compact('billsrch'));
}
else
{
return view ( 'pages.payBill',compact('billsrch'))->with('alert-danger', 'Sorry No details found');
}
}
}
While debugging my billPay
method, I am getting data from the database. Then how to show data in my view block. In previous forms I am displaying the data in a table, but now I need to show my data in form and update the paid column on button press PAY
. How can I do this?
route code block
Route::get('/billSearch','OrderedBookController@searchBill');
Route::post('/billPay','OrderedBookController@billPay');
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire