Неопределенная переменная: transaction_id, полученный
как я могу определить transaction_id в своем коде laravel? ниже приведен мой view_all_transaction.blade.php я застрял, может быть, кто-нибудь поможет мне это исправить.
Undefined variable: transaction_id (View:resources/views/view_all_transaction.blade.php)
<td><a href="{{action('AdminController@provetransaction', $view_all_transaction->transaction_id)}}" data-toggle="modal" data-target="#MyModal" class="btn btn-warning">Moderate</a></td> <!-- <td><button class="btn btn-success btn-sm" data-toggle="modal" data-target="#MyModal"> Approve</button></td> --> <div id="MyModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true"> <div class="modal-dialog modal-lg"> <!-- Modal Content: begins --> <div class="modal-content"> <!-- Modal Header --> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> <h4 class="modal-title" id="gridSystemModalLabel">Your Headings</h4> </div> <!-- Modal Body --> <div class="modal-body"> <div class="body-message"> <h4>Approve </h4> <div class="container"> <form method="post" action="{{action('AdminController@updateprove', $transaction_id)}}"> @csrf <div class="row"> <div class="col-md-4"></div> <div class="form-group col-md-4"> <lable>Approval</lable> <select name="approve"> <option value="0" @if($view_all_transaction->status==0)selected @endif>Pending</option> <option value="1" @if($view_all_transaction->status==1)selected @endif>Approve</option> <option value="2" @if($view_all_transaction->status==2)selected @endif>Reject</option> <option value="3" @if($view_all_transaction->status==3)selected @endif>Postponed</option> </select> </div> </div> <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button> <button type="submit" class="btn btn-default">Approve</button> <!-- <div class="row"> <div class="col-md-4"></div> <div class="form-group col-md-4"> <button type="submit" class="btn btn-success" style="margin-top:40px">Update</button> </div> </div> --> </form> </div> </div> </div> <!-- Modal Footer --> <div class="modal-footer"> <!-- <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button> <button type="submit" class="btn btn-success" style="margin-top:40px">Update</button> --> <!-- <button id="btnPrint" type="button" class="btn btn-default">Approve</button> --> </div> </div> <!-- Modal Content: ends -->
Что я уже пробовал:
мой adminController.php
public function provetransaction($transaction_id) { // $transaction_id = transaction::find ($req->transaction_id); $provetransaction = \DB::table('transaction')->where('transaction_id', $transaction_id)->first(); // return view('provetransaction'); // dd($request->all()); return view('provetransaction', compact('transaction', 'transaction_id')); } public function updateprove(Request $request, $transaction_id) { switch($request->get('approve')) { case 0: transaction::postpone($transaction_id); break; case 1: transaction::approve($transaction_id); break; case 2: transaction::reject($transaction_id); break; case 3: transaction::postpone($transaction_id); break; default: break; } return redirect('view_all_transaction'); }
мои маршруты web.php
Route::get('/view_all_transaction', 'AdminController@view_all_transaction')->name('admin'); Route::get('/view_all_transaction/provetransaction/{transaction_id}', 'AdminController@provetransaction')->name('admin'); Route::post('/view_all_transaction/{transaction_id}', 'AdminController@updateprove')->name('admin');