RouteCollection.php中的NotFoundHttpException行161:laravel 5.3

在拉拉维尔,我试图链接到一个特定的页面,但它正在显示

RouteCollection.php中的NotFoundHttpException行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 IlluminateDatabaseEloquentModel;

class Resource extends Model
{

    protected $table='resource';
    public $fillable=['resname'];
}

你在你的参数上犯错。 它应该{id}不是{$id}

更改

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

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

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

而Laravel 5.3现在支持使用name

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

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


看起来你的控制器文件中有一个“字符”

class FilesController extends Controller{
      public function deleteFile($id)//it was right here 
      {
          $file = Resource::find($id);
          Storage::delete(config('app.fileDestinationPath').'/'.$file->filename);
          $file->delete();
          return redirect()->to('/upload');
      }
}

尝试这个

链接地址: http://www.djcxy.com/p/94187.html

上一篇: NotFoundHttpException in RouteCollection.php line 161: laravel 5.3

下一篇: Ping via linux routing table not working [OR] how is this expected?