微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

RouteCollection.php第161行中的NotFoundHttpException:laravel 5.3

在laravel我试图链接一个特定的页面,但它正在显示

NotFoundHttpException in RouteCollection.PHP line 161:

这是我的代码,请帮我弄清楚错误
在我看来 :

{{ link_to_route('deleteFile','Delete',[$file->resid]) }}

在路线:

Route::get('/deleteFile/{$id}',['as'=>'deleteFile','uses'=>'FilesController@deleteFile']);

并在控制器中:

class FilesController extends Controller{
public function deleteFile($id)
    {

         $file = Resource::find($id);
      Storage::delete(config('app.fileDestinationPath').'/'.$file->filename);
        $file->delete();
        return redirect()->to('/upload');
    }}

这是我的型号代码

namespace App;

use Illuminate\Database\Eloquent\Model;

class Resource extends Model
{

    protected $table='resource';
    public $fillable=['resname'];
}
你在你的参数上犯了错误.应该{id}不是{$id}

更改

Route::get('/deleteFile/{$id}','uses'=>'FilesController@deleteFile']);

Route::get('/deleteFile/{id}','uses'=>'FilesController@deleteFile']);

链接https://laravel.com/docs/5.3/routing#required-parameters

和Laravel 5.3现在支持使用名称

Route::get('/deleteFile/{id}','FilesController@deleteFile')->name('deleteFile');

链接https://laravel.com/docs/5.3/routing#named-routes

原文地址:https://www.jb51.cc/laravel/134319.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。