1
我与laravel工作我同时发布的数据得到了一个错误,我创建controlle,模型,形成每一件事情。我用资源控制器和指定的路线,但我在这里给了下来,在此页面 有人可以帮助我的底部得到错误,我想这么大的变化路径,路线和每一件事情,但可能仍然能够提前获取Laravel错误
解决这个 谢谢我的形式
@extends('layouts.app')
@section('content')
<div class="row">
<div class="col-md-6 col-md-offset-3">
<div class="panel panel-default">
<div class="panel-heading">
Create Aticle
</div>
<div class="panel panel-body">
<form action="/l6/articles" class="form-group" method="POST" >
{{ csrf_field()}}
<input type="hidden" name="_method" value="" />
<label for="content">Content</label>
<textarea name="content" rows="4" cols="20" class="form-control"></textarea>
<div class="checkbox">
<div class="form-group">
<label for="live">
<input type="checkbox" name="live" >Live
</label>
</div>
</div>
<div class="form-group">
<label for="post_on">Posted On</label>
<input type="datetime-local" name="post_on" value="" class="form-control">
</div>
<button type="submit" name="submit" class="btn btn-success pull-right">Create</button>
</form>
</div
</div>
</div>
</div>
@endsection
我的控制器
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Article;
use Auth;
class ArticlesController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
//
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
return view('articles.create');
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$article = new Article;
$article->user_id = Auth::user()->id;
$article->content = $request->content;
$article->live = (boolean)$request->live;
$article->post_on = $request->post_on;
$article->save();
}
?>
Route is
Route::resource('/articles', 'ArticlesController');
(1/1) MethodNotAllowedHttpException
in RouteCollection.php (line 251)
at RouteCollection->methodNotAllowed(array('GET', 'HEAD', 'POST'))
in RouteCollection.php (line 238)
at RouteCollection->getRouteForMethods(object(Request), array('GET', 'HEAD', 'POST'))
in RouteCollection.php (line 176)
at RouteCollection->match(object(Request))
in Router.php (line 548)
at Router->findRoute(object(Request))
in Router.php (line 527)
at Router->dispatchToRoute(object(Request))
in Router.php (line 513)
at Router->dispatch(object(Request))
in Kernel.php (line 176)
我创建的功能是否正常工作的路线,但是当我点击提交按钮后有我有错误,意味着没有发布的数据到数据库,而不是它给了我错误我的路线是这样的 – Khalid
我的路线是 路线::资源(“/篇”,“ArticlesController”); – Khalid
@Khalid尝试在形式改变路线,把行动=“/篇” –