我有一个链接

<a class="trashButton" href="{{ URL::route('user.destroy',$members['id'][$i]) }}" style="cursor: pointer;"><i class="fa fa-trash-o"></i></a> 

this link is supposed to direct to the destroy method of the Usercontroller , this is my route Route::resource('/user', 'BackEnd\UsersController');

UserController是一个资源控制器.但是现在,它将我 bootstrap 到show方法,而不是DESTORT方法

推荐答案

This is because you are requesting the resources via GET method instead DELETE method. Look:

DELETE  /photo/{photo}  destroy     photo.destroy
GET     /photo/{photo}  show    photo.show

两个路由都有相同的URL,但标题动词标识要调用的地址.看起来是RESTful table.例如,通过ajax可以发送删除请求:

$.ajax({
    url: '/user/4',
    type: 'DELETE',  // user.destroy
    success: function(result) {
        // Do something with the result
    }
});

Laravel相关问答推荐

Laravel中的HTTP请求如何工作?

Hostinger Laravel网站未显示错误

Laravel AppServiceProvider 中的代码在通过 DeployHQ 部署时停止 Composer 和构建

Laravel 5.8 在从已清除的会话中单击注销后显示419 Page Expired

Laravel Valet 安装后 Ping test.dev 返回未知主机

使用 Amazon S3 的 Storage::get() 返回 false

Laravel:如何在 laravel 查询生成器中使用派生表/子查询

为什么 Laravel 5 会自动更新我的日期字段?

Laravel 5 如何全局设置 Cache-Control HTTP 标头?

Laravel 4 如何监听模型事件?

laravel:如何在 Eloquent Query 中使用 LOWERCASE 函数?

Laravel Eloquent:访问属性和动态表名

Laravel 4:读取由 javascript 设置的 cookie

Class类 App\Http\Controllers\Auth\Request 不存在.

Laravel 邮件密件抄送

控制器中的laravel foreach循环

如何在 Laravel 5.2 中使用 OR 条件将多个参数传递给中间件

你如何在 Laravel 中的每个响应上强制一个 JSON 响应?

如何使用 Postman 处理 Laravel $_POST 请求

带有 Xdebug 的 Laravel 5 总是抛出The payload is invalid..