问题 所有路线都正确输入并通过php artisan route检查:在这里列出输出
+--------+----------+------+--------+-------------------------------------------
-------+------------+
|←[32m Domain ←[39m|←[32m Method ←[39m|←[32m URI ←[39m|←[32m Name ←[39m|←[3
2m Action ←[39m|←[32m Middleware ←[39m
|
+--------+----------+------+--------+-------------------------------------------
-------+------------+
| | GET|HEAD | / | home | App\Http\Controllers\QuoteController@getIn
dex | web |
| | POST | new | create | App\Http\Controllers\QuoteController@addNe
wQuote | web |
| | GET|HEAD | test | test | App\Http\Controllers\QuoteController@getTe
st | web |
+--------+----------+------+--------+-------------------------------------------
-------+------------+
只有root路由才能正常工作
我尝试了什么:
home
localhost/quotes/public/index.php
BOOM它的工作原理.. 我的htaccess文件:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
正在努力:
Windows 10
XAMP
答案 0 :(得分:0)
首先写下你的表格
{!! Form::open(array('action' => 'QuoteController@store')) !!}
<table>
<tr>
<td><label for="author-form">Author Name:</label></td>
<td><input type="text" name="author-form" id="author-form" /></td>
</tr>
<tr>
<td><label for="quote-form">Quote:</label></td>
<td><textarea name="quote-form" id="quote-form" cols="30" rows="10"></textarea></td>
</tr>
<tr>
<td colspan='2'><button type="submit">Add Quote</button></td>
</tr>
<input type="hidden" name="_token" value="{{ Session::token() }}" />
</table>
{!!Form::close()!!}
现在对于路由部分,如果你使用laravel 5.2,你需要像这样在路由中分配web中间件
Route::group(['middleware' => 'web'], function () {
Route::resource('quate', 'QuoteController');
});
最后你的QuoteController创建了store方法,如果用artisan命令创建控制器,它会自动生成所有必需的方法
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
class QuoteController extends Controller
{
public function index(){
return view('welcome');
}
public function create(){
return view('test');
}
public function store(Request $request){
// Some Code here
}
}
现在当您在url中编写 quate 时,它会打开欢迎视图,当您编写create时,它会打开测试视图,这是我本地的代码。