I have a form and i am trying to update the forms. In the form, 'name' is a unique field (added the unique condition in request page and in a table, name is set as unique). when i try to update the form (i provided the value, the is already exist in the table), it shows 'MethodNotAllowedHttpException in RouteCollection.php line 219' error.
If i am update the 'name' with non-existing name that is not in table, it will work without any issues.
Router
Route::group(['middleware' => ['superadmin']], function () {
Route::post('/sadmin/update_club',array('uses' => 'SAdmin\ClubController@updateClub', 'as' => 'updateClub'));
}
Request
class UpdateClubRequest extends Request
{
public function authorize()
{
return true;
}
public function rules()
{
return [
'name' => 'required|max:150|unique:clubs,name,'.Request::input('id'),
'logo' => 'image|mimes:jpeg,png,bmp,gif,svg|max:10000',
];
}
}
Layout Page
{{ Form::open(array('route' => 'updateClub', 'method' => 'POST', 'class' => 'form-horizontal', 'files'=>true)) }}
{{ Form::hidden('id', $club[0]['id']) }}
{{ Form::text('name', $club[0]['name'], array('class' => 'form-control', 'maxlength' => 50)) }}
{{ Form::close() }}
MethodNotAllowedHttpException
is typically related toposting
to aget
route or vice versa, which is what the error message shows as well. By chance do you have aget
route defined to the same location above yourpost
route? – camelCase'/sadmin/update_club'
? – camelCase