Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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'=>'FacebookControllersPostsController@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');
    }
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
323 views
Welcome To Ask or Share your Answers For Others

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...