0
votes

I'm trying to update the edited data using auto generated update method in the controller. I edited the data by following process (Reference)

Controller :

public function edit($id)
{
    $user = Usermd::find($id);
    return View::make('editcreate', compact('user'));
}

Route :

Route::get('/user/edit/{id}', 'CreateUser@edit');

View :

{{ Form::model($user, ['url' => ['/user/update', $user->id]]) }}
   {{ Form::text('u_name',$user->u_name ) }}
   {!! Form::input('submit', 'Update User') !!}
{{ Form::close() }}

Above code is working fine for me, now i wanted to update the records.

Route :

Route::get('/user/update/{id}', 'CreateUser@update');

Controller :

 public function update(Request $request, $id)
    {
        //
        echo $request->u_name;
        echo $id;
    }

When i echo the request object in update method it does not showing anything and also returning the error

MethodNotAllowedHttpException in RouteCollection.php line 218:

Can anyone guide me where i'm wrong that i can fix this issue. Also i wanted to know the edit process is correct or i should search some better. I would like to appreciate if someone guide me. Thank You.

1
I think you should set Route post not getrad11
@rad11 yes I did and now its working. Thanks for sharing knowledgeAyaz Ali Shah
If you want you can name your route the same (i.e: /user/edit/{id}) as soon as their method (POST, GET, ...) is differentjeanj
Route::any('/user/update/{id}', 'CreateUser@update'); try itPardeep Pathania

1 Answers

0
votes

Default update is not using GET method, you should define you route by this:

Route::PUT('/user/update/{id}', 'CreateUser@update');