public function changeProfilePicture($id) { $user = $this->Users->get($id); $profilePic = UsersController::getProfilePic($user); if ($this->request->is(['patch', 'post', 'put'])) { $filename = $this->getFilename($user->id); move_uploaded_file($_FILES['profilePic']['tmp_name'], $this->usersFolder . $filename); $user->photo = $filename; if ($this->Users->save($user)) { $this->Flash->success(__('The profile picture has been updated')); return $this->redirect(['controller' => 'Users', 'action' => 'edit', $user->id]); } $this->Flash->error(__('Error')); } $this->set(['user' => $user, 'profilePic' => $profilePic]); }
public function viewFriendshipRequests() { $user = $this->Users->get($this->Auth->user()['id']); $this->loadModel('FriendRequests'); $results = $this->Users->find()->matching('States')->matching('Cities')->join(['table' => 'friend_requests', 'alias' => 'fr', 'type' => 'LEFT', 'conditions' => 'fr.user_requesting = users.id'])->where(['fr.user_requested' => $user->id]); $this->set(['user' => $user, 'friendshipRequest' => $this->getCountFriendshipRequests($user->id), 'profilePic' => UsersController::getProfilePic($user), 'results' => $results]); }