//web.php
// оказывается в MAMP нельзя использовать просто главную страницу для добавления -> '/'
Route::post('/', 'PostsController@addpost')->name('addpost');
// изменил рут на -> '/post/add'
Route::post('/post/add', 'PostsController@addpost')->name('addpost');
//web.php
Route::post('/', 'PostsController@addpost')->name('addpost');
//PostController
public function addpost(Request $request) {
$post = new Posts;
$post->title = $request->title;
$post->content = $request->content;
$post->save();
return redirect()->route('posts');
}
<form action="{{ route('addpost') }}" method="POST">
@csrf
<div class="form-group">
<label for="exampleFormControlInput1">Title</label>
<input type="text" class="form-control" id="exampleFormControlInput1" name='title' placeholder="Title">
</div>
<div class="form-group">
<label for="exampleFormControlTextarea1">Content</label>
<textarea name='content' class="form-control" id="exampleFormControlTextarea1" rows="3"></textarea>
</div>
<button type="submit" class="btn btn-primary">Send</button>
</form>