post request not working Laravel 5

落爺英雄遲暮 提交于 2019-12-17 21:18:47

问题


I am trying to submit a form using post method, but it does not seem to be working. I have enabled error debug on but still no error is shown. After submitting the form the same page is loaded without any errors. This is my route

Route::post('/home' , ['as' => 'store-post' , 'uses'=>'FacebookControllers\PostsController@save']);

And my form is

{!!  Form::open(['route'=>'store-post' , 'class'=>'form'])!!}
                   <div class="form-group">
                        <label for="textarea"></label>
                        <textarea class="form-control" rows="5" name="textarea">What's on your mind?</textarea>
                   </div>
                   <div class="form-group col-sm-12">
                         <input type="submit" value="Post" class="btn btn-primary pull-right">
                   </div
{!!  Form::close() !!}

This is my Controller

class PostsController extends Controller
{
    public function save(PostsRequests $request){

        $input = $request->all();
        $post = new Post();
        $post->user_id = Auth::user()->id;
        $post->content =$input;
        $post->user()->associate(1);
        $post->save();

        /*return redirect('home');*/
        return ('something');
    }
}

回答1:


After hours of searching and trying, finally, I found the solution. I was using my own request class and path was not correct so I corrected the path of PostsRequests and now it works.



来源:https://stackoverflow.com/questions/32113117/post-request-not-working-laravel-5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!