在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
Route::get('/deleteFile/{id}','FilesController@deleteFile')->name('deleteFile');
原文地址:https://www.jb51.cc/laravel/134319.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。