【发布时间】:2021-10-11 17:35:23
【问题描述】:
我正在学习 Laravel,添加删除路由时遇到路由错误
Symfony\Component\Routing\Exception\RouteNotFoundException 路线 [deletestyle/] 未定义。 (查看:G:\xampp\htdocs\CMS\resources\views\styles\style.blade.php)
路线
Route::delete('/deletestyle/{id}', 'StyleController@destroy');
控制器
public function destroy($id){
try{
$style = Style::findorFail($id);
if($style->delete()){
return response()->json(['status' => 'success', 'message' => 'Style deleted successfully']);
}
}catch(\Exception $e){
return response()->json(['status' => 'error', 'message' => $e->getMessage()]);
}
}
查看
<a class="dropdown-item text-danger" href="{{ route('deletestyle/').$style->id }}">Delete</a></div>
【问题讨论】: