當我郵寄的形式向控制器的laravel顯示了這個錯誤:Laravel 5.3:方法[演出]不存在
Method PTA_OIMS\Http\Controllers\InstructionsController::show() does not exist in /home/rad/public_html/pta_oims/vendor/laravel/framework/src/Illuminate/Routing/Route.php:333
這是我的web.php文件:
Route::post('instructions/view','[email protected]')->name('view');
Route::post('instructions/assign','[email protected]');
Route::get('instructions/sent','[email protected]')->name('sent');
Route::post('instructions/reject','[email protected]')->name('reject');
Route::resource('instructions','InstructionsController');
和刀片觀點:
<form action=" {{url('instructions/assign')}}"
成了更完整:
InstructionsController並加入顯示(),視圖()和分配()方法
public function show()
{
return 'show() method done!!';
}
視圖()方法
public function view(Request $request)
{
$boxes = $this->getBoxesList();
$id = $request->input('id');
$data = Kartable::where('id', '=', $id)
->with('instruction')
->first();
if ($data->view_date == NULL) {
$this->insertViewDate($id);
}
return view('instructions.view', array('data' => $data, 'boxes' => $boxes));
}
視圖葉片文件,發送所述數據到分配的形式()方法:
<form method="POST" action=" {{url('instructions/assign')}}"
class="form-horizontal" role="form" data-toggle="validator">
{{csrf_field()}}
分配()方法
public function assign(Request $input)
{
try {
$inst_id = $input->input('inst_id');
// $childsInsts = Instructions::where('parent_id', '=', $inst_id)
// ->where('status', '=', 0)
// ->get();
$formData = $input->all();
$step = 0;
foreach ($formData['box'] as $box) {
foreach ($box as $id_reciver)
DB::transaction(function() use ($formData, $inst_id, $id_reciver, $step) {
$kar = new Kartable();
$kartable_id = $formData['kartable_id'];
$current_box = $formData['current_box'];
$kar->inst_id = $inst_id;
$kar->parent_id = $kartable_id;
$kar->id_sender = $current_box;
$kar->id_reciver = $id_reciver;
$kar->status = 1;
$kar->save(); // insert for new record of kartable
$step += 1;
if ($step < 2) {
$kartable = new Kartable();
$kartable
->where('id', '=', $kartable_id)
->update(['status' => 3]); //change status of old row kartable
}
});
return redirect()->route('instructions.index');
}
} catch (\Exception $e) {
dd($e);
}
}
問題已更新 –