Laravel Controller update method not working

I am new to Laravel.

I created a controller, model and views by method / generator by composer php artisan generate:scaffold citiesand its index page (Create and store method). Works well, but I don't know what the problem is with update.

This is my CitiesController method ( Update ):

public function update($id)
{
    $city = City::findOrFail($id);

    $validator = Validator::make($data = Input::all(), City::$rules);

    if ($validator->fails())
    {
        return Redirect::back()->withErrors($validator)->withInput();
    }

    $city->update($data);
    return Redirect::route('admin.cities.index');
}

This is my model ( city ):

class City extends \Eloquent {
   protected $primaryKey='city_id';

    public static $rules = [
         'name'     => 'required',
         'image'     => 'mimes:jpeg',
         'parent_id' => 'required',
         'name'      => 'required',
         'english_name'=>'unique:cities,english_name|required'

    ];
    protected $fillable = ['name', 'parent_id', 'english_name','population','phone_prefix','image'];
}

And this is my view ( change ):

<ul>
    {{ Form::model($city,array('route'=>array('admin.cities.update',$city->id),'method'=>'PUT','files'=>true)) }}
    <!--Here I included my form-->
    @include('admin.forms._partial.formcity')
    <li>
        {{ Form::submit('submit') }}
    </li>
    {{ Form::close() }}
</ul>

And this is my route:

Route::group(array('prefix'=>'admin','before'=>'Auth'),function(){
    Route::resource('cities', 'CitiesController');
});

When I click the submit button, Laravel throws this error:

Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException

note. . , , , create store, .

+1
1

protected $primaryKey='city_id';, , , :

{{ Form::model($city,array('route'=>array('admin.cities.update',$city->id),'method'=>'PUT','files'=>true)) }}

$city->id $city->city_id

0

All Articles