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');
}
}
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