/var/www/vhosts/ihelp.ro/_OLD/src/Controller
Edit: /var/www/vhosts/ihelp.ro/_OLD/src/Controller/ProfilesController.php (4320B)
Authorization->skipAuthorization();
// $this->paginate = [
// 'contain' => ['Users', 'UserAcceptContactMethods'],
// ];
// $profiles = $this->paginate($this->Profiles);
// $this->set(compact('profiles'));
// }
/**
* View method
*
* @param string|null $id Profile id.
* @return \Cake\Http\Response|null|void Renders view
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
*/
public function view()
{
$this->Authorization->skipAuthorization();
$profile_id = $this->Profiles->find()->where(['user_id' => $this->userAuth->id])->first();
$id = $profile_id->id;
$profile = $this->Profiles->get($id, [
'contain' => ['Users'],
]);
$this->set(compact('profile'));
}
// /**
// * Add method
// *
// * @return \Cake\Http\Response|null|void Redirects on successful add, renders view otherwise.
// */
// public function add()
// {
// $this->Authorization->skipAuthorization();
// $user_id = $this->userAuth->id;
// $profile = $this->Profiles->newEmptyEntity();
// if ($this->request->is('post')) {
// $profile = $this->Profiles->patchEntity($profile, $this->request->getData());
// if ($this->Profiles->save($profile)) {
// $this->Flash->success(__('The profile has been saved.'));
// return $this->redirect(['action' => 'index']);
// }
// $this->Flash->error(__('The profile could not be saved. Please, try again.'));
// }
// $users = $this->Profiles->Users->find('list', ['limit' => 200]);
// $userAcceptContactMethods = $this->Profiles->UserAcceptContactMethods->find('list', ['limit' => 200]);
// $this->set(compact('profile', 'users', 'userAcceptContactMethods'));
// }
/**
* Edit method
*
* @param string|null $id Profile id.
* @return \Cake\Http\Response|null|void Redirects on successful edit, renders view otherwise.
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
*/
public function edit()
{
$this->Authorization->skipAuthorization();
$profile_id = $this->Profiles->find()->where(['user_id' => $this->userAuth->id])->first();
$id = $profile_id->id;
$profile = $this->Profiles->get($id, [
'contain' => [],
]);
if ($this->request->is(['patch', 'post', 'put'])) {
$profile = $this->Profiles->patchEntity($profile, $this->request->getData());
if ($this->Profiles->save($profile)) {
$this->Flash->success(__('The profile has been saved.'));
return $this->redirect(['action' => 'view']);
}
$this->Flash->error(__('The profile could not be saved. Please, try again.'));
}
$users = $this->Profiles->Users->find('list', ['limit' => 200]);
$this->set(compact('profile', 'users'));
}
/**
* Delete method
*
* @param string|null $id Profile id.
* @return \Cake\Http\Response|null|void Redirects to index.
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
*/
public function delete($id = null)
{
$this->request->allowMethod(['post', 'delete']);
$profile = $this->Profiles->get($id);
if ($this->Profiles->delete($profile)) {
$this->Flash->success(__('The profile has been deleted.'));
} else {
$this->Flash->error(__('The profile could not be deleted. Please, try again.'));
}
return $this->redirect(['action' => 'index']);
}
}