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

Categories

0 votes
338 views
in Technique[技术] by (71.8m points)

html - post request not working Laravel 5

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

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

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...