2

I'm new to laravel and I would like to add another Update method from the created resource controller UsersController. something like this:

  public function update(Request $request, $id)
{
    "logic here"
}
  public function update2(Request $request, $id)
{
    "logic here"
}

but i do not know how to access "update2". is there a way to do this?

Evan
  • 2,327
  • 5
  • 31
  • 63

3 Answers3

2

You would only need add another route to your routes/web.php file. For example:

Route::post('/users/{user}/update2', 'UsersController@update2');

As you've mentioned it being a resource controller, you may have already added something similar to:

Route::resource('users', 'UsersController');

This will create the corresponding index, show, store, update, and destroy routes.

Brian Lee
  • 17,904
  • 3
  • 41
  • 52
0

You can simply access update2 like this :

Route::get('route-name', 'YourCOntroller@update2');
dvl333
  • 183
  • 1
  • 12
-1

Resource route will create URL like user/{id}

You have to create another route for the update2 in web.php like

Route::put('user/{id}/update2', 'V1\UserController@update2');