私は、例えばのIDを持つ私のドキュメントモデルをソフト削除しようとしています。私はすでにメソッドとして私の形で宣言しています。Route::delete
関数も定義しています。私のドキュメントモデルではすでにuse SoftDeletes;
を定義していますが、私にはMethodNotAllowedHttpExceptionがスローされていますなぜこのエラーが出るのですか?ヒントをありがとうか助け:)MethodNotAllowedHttpException SoftDeleteを使用して
路線:
Route::get('/documents/pending',
[
'uses' => '\App\Http\Controllers\[email protected]',
'as' => 'document.pending',
]);
Route::delete('/documents/pending/{id}/hide',
[
'uses' => '\App\Http\Controllers\[email protected]',
'as' => 'document.softDeletePending',
]);
コントローラー:
public function hideApprovalsDocument(Document $id)
{
$hide = Document::find($id);
$hide->delete();
return redirect()->back();
}
ビュー:
@foreach ($pendingDocuments as $list)
<tr class = "info">
<td>
<form class = "form-inline" role = "form" method = "DELETE" action = "/documents/pending/{{ $list->documentId }}/hide">
<div class = "form-group">
<a href = "{{ route ('document.softDeletePending', $list->documentId) }}"><button type = "submit" class = "btn btn-danger glyphicon glyphicon-eye-close"> Hide</button></a>
</div>
</form>
</td>
</tr>
@endforeach
スタックトレース:
in RouteCollection.php line 219
at RouteCollection->methodNotAllowed(array('DELETE')) in RouteCollection.php line 206
at RouteCollection->getRouteForMethods(object(Request), array('DELETE')) in RouteCollection.php line 158
at RouteCollection->match(object(Request)) in Router.php line 823
at Router->findRoute(object(Request)) in Router.php line 691
at Router->dispatchToRoute(object(Request)) in Router.php line 675
at Router->dispatch(object(Request)) in Kernel.php line 246
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Debugbar.php line 51
at Debugbar->handle(object(Request), object(Closure))
at call_user_func_array(array(object(Debugbar), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 44
at CheckForMaintenanceMode->handle(object(Request), object(Closure))
at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Kernel.php line 132
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 99
at Kernel->handle(object(Request)) in index.php line 54