【发布时间】:2018-12-15 09:21:11
【问题描述】:
PostsController.php
public function store(Request $request)
{
Post::create($request->all());
return redirect('/posts');
}
我在帖子目录中的视图 create.blade.php
@extends('layout.app')
@section('content')
<h1>Create Post</h1>
<form action="/posts" method="post">
<input type="text" name="title" placeholder="Enter title"> <!-- this name=title comes from create_posts_table -->
{{--{{csrf_field()}}--}}
<input type="submit" name="submit">
</form>
@stop
路线
Route::resource('/posts','PostsController');
当我提交浏览器转到 localhost/posts 并显示:
Object not found!
The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error.
If you think this is a server error, please contact the webmaster.
Error 404
localhost
Apache/2.4.33 (Win32) OpenSSL/1.1.0h PHP/7.2.5
没有记录不会保存
【问题讨论】:
-
您是否将文档根设置为
/public? -
这是唯一有此问题的路线吗?
-
@ChinLeung /posts/
-
@Nima 是的,更新也不起作用
-
我认为@ChinLeung 的意思是您的 Apache 或 Web 服务器 DocumentRoot 是否设置为 Laravel 源代码中的 /public 文件夹?
标签: php laravel forms redirect store