|string> */ public function rules(): array { $userId = $this->route('user') ? $this->route('user')->id : null; return [ 'name' => 'required|string', 'email' => 'required|email|unique:users,email' . ($userId ? ',' . $userId : ''), 'password' => $this->isMethod('POST') ? 'required|string|min:6' : 'nullable|string|min:6', 'password_confirmation' => $this->isMethod('POST') ? 'required|same:password' : 'nullable|same:password', 'roles' => 'required' ]; } }