jeudi 28 janvier 2016

Getting MethodNotAllowedHttpException in RouteCollection.php line 219: on laravel

Im getting the errors above. I tried to read on other forums with the same problem but with no luck. My create, store and edit are working. However when updating my form im getting the error above. Can someone help me on this. Thanks

{!! Form::open(['method'=>'POST','url'=>['/enrollment',$enrollment->id],'class'=>'form-horizontal']) !!}

                <div class="form-group">
                    <label for="subject_code" class="col-md-3 control-label">Subject Code</label>
                    <div class="col-md-8">
                        <select class="form-control" name="_method" value="PUT" id="subject_code">
                            <option value="{{ $enrollment->subject_code }}">{{ $enrollment->subject_code }}</option>
                            @foreach($subjects as $subject)
                                <option value="{{ $subject->subject_code }}">{{ $subject->subject_code}}</option>
                            @endforeach 
                        </select>
                    </div>

                </div>

                <div class="form-group">
                    <label for="subject_description" class="col-md-3 control-label">Subject description</label>
                    <div class="col-md-8">
                        <select class="form-control" name="subject_description" id="subject_description">
                            <option value="{{ $enrollment->subject_description }}">{{ $enrollment->subject_description }}</option>
                            @foreach($subjects as $subject)
                                <option value="{{ $subject->subject_description }}">{{ $subject->subject_description}}</option>
                            @endforeach 
                        </select>
                    </div>

                </div>


                <div class="form-group">
                    <label for="subject_code" class="col-md-3 control-label">Subject Code</label>
                    <div class="col-md-8">
                        <select class="form-control" name="subject_code" id="subject_code">
                            <option value="{{ $enrollment->section }}">{{ $enrollment->section}}</option>
                            @foreach($sections as $section)
                                <option value="{{ $section }}">{{ $section }}</option>
                            @endforeach
                        </select>
                    </div>

                </div>


                <div class="form-group">
                    <label for="subject_code" class="col-md-3 control-label">Subject Code</label>
                    <div class="col-md-8">
                        <select class="form-control" name="subject_code" id="subject_code">
                            <option value="{{ $enrollment->schedule }}">{{ $enrollment->schedule }}</option>
                            @foreach($subjects as $subject)
                                <option value="{{ $subject->schedule }}">{{ $subject->schedule}}</option>
                            @endforeach 
                        </select>
                    </div>

                </div>  

                <div class="form-group">
                    <label for="subject_code" class="col-md-3 control-label">Subject Code</label>
                    <div class="col-md-8">
                        <select class="form-control" name="subject_code" id="subject_code">
                            <option value="{{ $enrollment->no_of_units }}">{{ $enrollment->no_of_units }}</option>
                            @foreach($subjects as $subject)
                                <option value="{{ $subject->no_of_units }}">{{ $subject->no_of_units}}</option>
                            @endforeach 
                        </select>
                    </div>

                </div>
                <div class="form-group">
                    <div class="col-md-7 col-md-offset-3">

                        <button type="submit" class="btn btn-success">
                            <i class="fa fa-save"></i>
                            &nbsp;Save Changes
                        </button>

                        <button type="submit" class="btn btn-danger">
                            <i class="fa fa-times-circle"></i>
                            &nbsp;Delete
                        </button>
                    </div>
                </div>                                                                              
{!! Form::close() !!}

Here's my EnrollmentController:

    public function update(EnrollmentRequest $request, $id)
{
    $enrollment = Enrollment::findOrFail($id);
    $enrollment->update($request->all());
    return redirect('/enrollment');
}

routes.php

// Authentication routes...
Route::get('auth/login', 'Auth\AuthController@getLogin');
Route::post('auth/login', 'Auth\AuthController@postLogin');
Route::get('auth/logout', 'Auth\AuthController@getLogout');

// Registration routes...
Route::get('auth/register', 'Auth\AuthController@getRegister');
Route::post('auth/register', 'Auth\AuthController@postRegister');

Route::resource('enrollment','EnrollmentController');



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire