(1/1)MethodNotAllowedHttpException [英] (1/1) MethodNotAllowedHttpException

查看:70
本文介绍了(1/1)MethodNotAllowedHttpException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过写入web.php

"Route::get('/owner-information/edit/{id}', ['as' => 'owner-information.edit', 'uses' => 'OwnerInformatiionController@edit']);

index.blade.php

{{ route('owner-information.update', $owner_info->id) }}

,单击更新后,将显示以下错误:

and after clicking update it shows thee following error:

(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 546)
at Router->findRoute(object(Request))
in Router.php (line 525)

推荐答案

edit.blade.php @extends('owner-information.base')

edit.blade.php @extends('owner-information.base')

@section('action-content')
<div class="container">
<div class="row">
    <div class="col-md-8 col-md-offset-2">
        <div class="panel panel-default">
            <div class="panel-heading">Update Owner Information</div>
            <div class="panel-body">
                <form class="form-horizontal" role="form"  action="{{ route('owner-information.update', $owner_info->id) }}" method="post">
                    <input type="hidden" name="_method" value="PATCH">
                    <input type="hidden" name="_token" value="{{ csrf_token() }}">
                    <div class="form-group{{ $errors->has('first_name') ? ' has-error' : '' }}">
                        <label for="first_name" class="col-md-4 control-label">First Name</label>

                        <div class="col-md-6">
                            <input id="first_name" type="text" class="form-control" name="first_name" value="{{ $owner_info->first_name }}" required autofocus>

                            @if ($errors->has('first_name'))
                                <span class="help-block">
                                    <strong>{{ $errors->first('first_name') }}</strong>
                                </span>
                            @endif
                        </div>
                    </div>
                    <div class="form-group{{ $errors->has('mid_name') ? ' has-error' : '' }}">
                        <label for="mid_name" class="col-md-4 control-label">Middle Name</label>

                        <div class="col-md-6">
                            <input id="mid_name" type="text" class="form-control" name="mid_name" value="{{ $owner_info->mid_name }}" required autofocus>

                            @if ($errors->has('mid_name'))
                                <span class="help-block">
                                    <strong>{{ $errors->first('mid_name') }}</strong>
                                </span>
                            @endif
                        </div>
                    </div>
                    <div class="form-group{{ $errors->has('last_name') ? ' has-error' : '' }}">
                        <label for="last_name" class="col-md-4 control-label">Last Name</label>

                        <div class="col-md-6">
                            <input id="last_name" type="text" class="form-control" name="last_name" value="{{ $owner_info->last_name }}" required autofocus>

                            @if ($errors->has('last_name'))
                                <span class="help-block">
                                    <strong>{{ $errors->first('last_name') }}</strong>
                                </span>
                            @endif
                        </div>
                    </div>
                     <div class="form-group{{ $errors->has('flat_no') ? ' has-error' : '' }}">
                        <label for="flat_no" class="col-md-4 control-label">Flat No</label>

                        <div class="col-md-6">
                            <input id="flat_no" type="text" class="form-control" name="flat_no" value="{{ $owner_info->flat_no }}" required autofocus>

                            @if ($errors->has('flat_no'))
                                <span class="help-block">
                                    <strong>{{ $errors->first('flat_no') }}</strong>
                                </span>
                            @endif
                        </div>
                    </div>
                    <div class="form-group{{ $errors->has('car_park') ? ' has-error' : '' }}">
                        <label for="car_park" class="col-md-4 control-label">Parking No</label>

                        <div class="col-md-6">
                            <input id="car_park" type="text" class="form-control" name="car_park" value="{{ $owner_info->car_park }}" required autofocus>

                            @if ($errors->has('car_park'))
                                <span class="help-block">
                                    <strong>{{ $errors->first('car_park') }}</strong>
                                </span>
                            @endif
                        </div>
                    </div>
                    <div class="form-group{{ $errors->has('mobile_no') ? ' has-error' : '' }}">
                        <label for="mobile_no" class="col-md-4 control-label">Mobile No</label>

                        <div class="col-md-6">
                            <input id="mobile_no" type="text" class="form-control" name="mobile_no" value="{{ $owner_info->mobile_no }}" required>

                            @if ($errors->has('mobile_no'))
                                <span class="help-block">
                                    <strong>{{ $errors->first('mobile_no') }}</strong>
                                </span>
                            @endif
                        </div>
                    </div>
                    <div class="form-group{{ $errors->has('email_id') ? ' has-error' : '' }}">
                        <label for="email_id" class="col-md-4 control-label">Email Address</label>

                        <div class="col-md-6">
                            <input id="email_id" type="text" class="form-control" name="email_id" value="{{ $owner_info->email_id }}" required>

                            @if ($errors->has('email_id'))
                                <span class="help-block">
                                    <strong>{{ $errors->first('email_id') }}</strong>
                                </span>
                            @endif
                        </div>
                    </div>
                    <div class="form-group{{ $errors->has('n_id') ? ' has-error' : '' }}">
                        <label for="n_id" class="col-md-4 control-label">National ID</label>

                        <div class="col-md-6">
                            <input id="n_id" type="text" class="form-control" name="n_id" value="{{ $owner_info->n_id }}" required autofocus>

                            @if ($errors->has('n_id'))
                                <span class="help-block">
                                    <strong>{{ $errors->first('n_id') }}</strong>
                                </span>
                            @endif
                        </div>
                    </div>
                    <div class="form-group{{ $errors->has('date_of_birth') ? ' has-error' : '' }}">
                        <label for="date_of_birth" class="col-md-4 control-label">Date of Birth</label>

                        <div class="col-md-6">
                            <input id="date_of_birth" type="text" class="form-control" name="date_of_birth" value="{{ $owner_info->date_of_birth }}" required autofocus>

                            @if ($errors->has('date_of_birth'))
                                <span class="help-block">
                                    <strong>{{ $errors->first('date_of_birth') }}</strong>
                                </span>
                            @endif
                        </div>
                    </div>
                     <div class="form-group{{ $errors->has('present_add') ? ' has-error' : '' }}">
                        <label for="present_add" class="col-md-4 control-label">Present Address</label>

                        <div class="col-md-6">
                            <input id="present_add" type="text" class="form-control" name="present_add" value="{{ $owner_info->present_add }}" required autofocus>

                            @if ($errors->has('present_add'))
                                <span class="help-block">present_add
                                    <strong>{{ $errors->first('present_add') }}</strong>
                                </span>
                            @endif
                        </div>
                    </div>
                    <div class="form-group{{ $errors->has('parmanent_add') ? ' has-error' : '' }}">
                        <label for="parmanent_add" class="col-md-4 control-label">Parmanent Address</label>

                        <div class="col-md-6">
                            <input id="parmanent_add" type="text" class="form-control" name="parmanent_add" value="{{ $owner_info->parmanent_add }}" required>

                            @if ($errors->has('parmanent_add'))
                                <span class="help-block">
                                    <strong>{{ $errors->first('parmanent_add') }}</strong>
                                </span>
                            @endif
                        </div>
                    </div>
                    <div class="form-group{{ $errors->has('emergency_contact') ? ' has-error' : '' }}">
                        <label for="emergency_contact" class="col-md-4 control-label">Emergency Contact</label>

                        <div class="col-md-6">
                            <input id="emergency_contact" type="text" class="form-control" name="emergency_contact" value="{{ $owner_info->emergency_contact }}" required>

                            @if ($errors->has('emergency_contact'))
                                <span class="help-block">
                                    <strong>{{ $errors->first('emergency_contact') }}</strong>
                                </span>
                            @endif
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-md-6 col-md-offset-4">
                            <button type="submit" class="btn btn-primary">
                                Update
                            </button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
</div>
 @endsection

在控制器中: 公共功能更新(请求$ request,$ id) { $ owner_info = OwnerInfo :: findOrFail($ id); //$ this-> validateInput($ request); $ temp = str_replace('/','-',$ request-> date_of_birth); $ date =新的DateTime($ temp); $ input = [ 'first_name'=> $ request ['first_name'], 'mid_name'=> $ request ['mid_name'], 'last_name'=> $ request ['last_name'], 'flat_no'=> $ request ['flat_no'], 'car_park'=> $ request ['car_park'], 'mobile_no'=> $ request ['mobile_no'], 'email_id'=> $ request ['email_id'], 'n_id'=> $ request ['n_id'], 'date_of_birth'=> $ request ['date'], 'present_add'=> $ request ['present_add'], 'parmanent_add'=> $ request ['parmanent_add'], 'emergency_contact'=> $ request ['emergency_contact']

In controller: public function update(Request $request, $id) { $owner_info = OwnerInfo::findOrFail($id); // $this->validateInput($request); $temp= str_replace('/', '-',$request->date_of_birth); $date = new DateTime($temp); $input = [ 'first_name'=> $request['first_name'], 'mid_name' => $request['mid_name'], 'last_name'=> $request['last_name'], 'flat_no' => $request['flat_no'], 'car_park'=> $request['car_park'], 'mobile_no' => $request['mobile_no'], 'email_id' => $request['email_id'], 'n_id' => $request['n_id'], 'date_of_birth' => $request['date'], 'present_add' => $request['present_add'], 'parmanent_add' => $request['parmanent_add'], 'emergency_contact' => $request['emergency_contact']

          ];
      if ($request->file('picture')) {
        $path = $request->file('picture')->store('avatars');
        $input['picture'] = $path;
    }
    OwnerInfo::where('id', $id)
        ->update($input);
    return redirect()->intended('owner-information');
 }

这篇关于(1/1)MethodNotAllowedHttpException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆