【发布时间】:2019-02-07 14:07:54
【问题描述】:
所以目前我的“存储”资源控制器添加到我的数据库中的表并获取我的“索引”页面(我的主页)的视图但是当我刷新此视图时,它会复制添加到数据库的最后一行.我注意到 URI 是 'http://127.0.0.1:8000/store' 而不是 'http://127.0.0.1:8000/index' 有人能解释一下发生了什么吗?对于缺乏技术术语,我深表歉意,我是一名新学徒,我正在尝试使用自己的主动性来解决这个问题,但到目前为止还没有运气。我还注意到我的注销功能做了同样的事情,尽管 URI 略有不同,它仍然在 URI 中显示 CSRF 令牌,但它仍然在“注销”文件路径中显示它,这是一个示例; 'http://127.0.0.1:8000/logout?_token=bqTl4J3EZyKj7LS5ZvqfRB8k1Qg02IT1j4WlBG51&dir2login='
仅供参考,我已经尝试过 return $this->index();
我的注销控制器方法;
public function logout(){
Auth::logout();
return view('index',['posts'=>$this->getTable()]);
}
我的商店控制器方法:
public function store(Request $request){
//creates new row in database table
//$clientIp=$request->ip();
$post = new PostModel();
//gets email of user currently logged in
$post->email=Auth::user()->email;
$post->ip=$request->ip();
$post->content=$request->content;
$post->company=$request->company;
$post->rating=$request->rating;
//saves to database
$post->save();
return view('index',['posts'=>$this->getTable()]);
}
【问题讨论】:
-
控制器中是否还有
index()? -
你能提供你的
index()和你的路线吗?
标签: php html laravel url homestead