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

前端之家收集整理的这篇文章主要介绍了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.f2er.com/laravel/134319.html

猜你在找的Laravel相关文章