Php 使用laravel 5获取MethodNotAllowedException
大家好,我是Laravel的新手,我正在关注有关视图部分和表单重用的Laracast 我正在进入编辑页面。html如下所示:Php 使用laravel 5获取MethodNotAllowedException,php,html,rest,laravel-5,Php,Html,Rest,Laravel 5,大家好,我是Laravel的新手,我正在关注有关视图部分和表单重用的Laracast 我正在进入编辑页面。html如下所示: @extends('app') @section('content') <h1>Edit: {!! $edu_content->title !!} </h1> {!! Form::model($edu_content, ['method' => 'PATCH', 'url' => 'edu_contents/' . $edu_
@extends('app')
@section('content')
<h1>Edit: {!! $edu_content->title !!} </h1>
{!! Form::model($edu_content, ['method' => 'PATCH', 'url' => 'edu_contents/' . $edu_content->id ]) !!}
<div class="form-group">
{!! Form::label('title', 'Title:') !!}
{!! Form::text('title', null, ['class' => 'form-control']) !!}
</div>
<div class="form-group">
{!! Form::label('tags', 'Tags:') !!}
{!! Form::text('tags', null, ['class' => 'form-control']) !!}
</div>
<div class="form-group">
{!! Form::label('user_id', 'User ID:') !!}
{!! Form::text('user_id', null, ['class' => 'form-control']) !!}
</div>
<div class="form-group">
{!! Form::label('location', 'Location:') !!}
{!! Form::text('location', null, ['class' => 'form-control']) !!}
</div>
<div class="form-group">
{!! Form::label('file_size', 'File Size:') !!}
{!! Form::text('file_size', null, ['class' => 'form-control']) !!}
</div>
<div class="form-group">
{!! Form::label('uploaded_at', 'Created On:') !!}
{!! Form::input('date','uploaded_at', date('Y-m-d'), ['class' => 'form-control']) !!}
</div>
<div class="form-group">
{!! Form::submit('Add Edu content!', ['class' => 'btn btn-primary form-control']) !!}
</div>
{!! Form::close() !!}
@if ($errors->any())
<ul class="alert alert-danger">
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
@endif
@stop
有人能解释这个错误以及为什么id没有出现在动作中吗
我的路由看起来像
Route::resource('edu_contents','educontentscocontroller')代码>尝试更改执行操作的方式。尝试此方法(使用自己的方法更改更新方法):
而不是:
'url' => 'edu_contents/' . $edu_content->id
这个$edu_content->title可以打印标题吗?如果是,那一个:$edu_content->id可以打印出什么?您是否尝试使用POST而不是补丁,请查看laravel文档,HTML表单不支持PUT、PATCH或DELETEactions@narendra我一直在遵循laracasts,这是他们建议的做法。@Panagiotis当我有$edu_content->id时,它就会被打印出来:动作="http://localhost/edu_contents/5/edit“
。奇怪的是,您是否为Laravel安装了HTML和表单生成器
'action' => ['EduContentsController@update', $edu_content->id
'url' => 'edu_contents/' . $edu_content->id