Reputation: 23
Well, if I want to change user's email, for example, do I need to make a new controller with protected function update(array $data)
, or I can write it somewhere else?
Upvotes: 0
Views: 156
Reputation: 476
I will assume that you have update function inside UserController for updating user info and you want another function to update only the email.
Yes you can add other functions in the same controller as many as you want but all the functions should be related to each other For example all operations for users should be in UserController dont add operation for posts for example
//UserController.php
public function update(Request $request,User $user){
//update user info
}
public function updateEmail(Request $request,User $user){
//update user email
$user->update(['email'=>$request->get('email')])
}
Upvotes: 2