Laravel can I add two update method on a resource controller [duplicate]
This question already has an answer here:
Add new methods to a resource controller in Laravel
7 answers
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?
laravel php-7 laravel-5.7 laravel-controller
marked as duplicate by Community♦ Nov 22 '18 at 5:37
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
Add new methods to a resource controller in Laravel
7 answers
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?
laravel php-7 laravel-5.7 laravel-controller
marked as duplicate by Community♦ Nov 22 '18 at 5:37
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
Add new methods to a resource controller in Laravel
7 answers
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?
laravel php-7 laravel-5.7 laravel-controller
This question already has an answer here:
Add new methods to a resource controller in Laravel
7 answers
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?
This question already has an answer here:
Add new methods to a resource controller in Laravel
7 answers
laravel php-7 laravel-5.7 laravel-controller
laravel php-7 laravel-5.7 laravel-controller
edited Nov 21 '18 at 5:09
Vanz
asked Nov 21 '18 at 4:51
VanzVanz
12112
12112
marked as duplicate by Community♦ Nov 22 '18 at 5:37
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by Community♦ Nov 22 '18 at 5:37
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
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.
add a comment |
You can simply access update2 like this :
Route::get('route-name', 'YourCOntroller@update2');
add a comment |
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', 'V1UserController@update2');
add a comment |
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
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.
add a comment |
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.
add a comment |
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.
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.
answered Nov 21 '18 at 5:47


DigitalDrifterDigitalDrifter
8,3382624
8,3382624
add a comment |
add a comment |
You can simply access update2 like this :
Route::get('route-name', 'YourCOntroller@update2');
add a comment |
You can simply access update2 like this :
Route::get('route-name', 'YourCOntroller@update2');
add a comment |
You can simply access update2 like this :
Route::get('route-name', 'YourCOntroller@update2');
You can simply access update2 like this :
Route::get('route-name', 'YourCOntroller@update2');
answered Nov 21 '18 at 5:46


dvl333dvl333
495
495
add a comment |
add a comment |
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', 'V1UserController@update2');
add a comment |
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', 'V1UserController@update2');
add a comment |
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', 'V1UserController@update2');
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', 'V1UserController@update2');
answered Nov 21 '18 at 5:47
Hardik PrajapatiHardik Prajapati
502
502
add a comment |
add a comment |