/var/www/vhosts/ihelp.ro/httpdocs/vendor/cakedc/users/src/Controller/Traits
Edit: /var/www/vhosts/ihelp.ro/httpdocs/vendor/cakedc/users/src/Controller/Traits/SimpleCrudTrait.php (4488B)
loadModel();
$tableAlias = $table->getAlias();
$this->set($tableAlias, $this->paginate($table));
$this->set('tableAlias', $tableAlias);
$this->set('_serialize', [$tableAlias, 'tableAlias']);
}
/**
* View method
*
* @param string|null $id User id.
* @return void
* @throws \Cake\Http\Exception\NotFoundException When record not found.
*/
public function view($id = null)
{
$table = $this->loadModel();
$tableAlias = $table->getAlias();
$entity = $table->get($id, [
'contain' => [],
]);
$this->set($tableAlias, $entity);
$this->set('tableAlias', $tableAlias);
$this->set('_serialize', [$tableAlias, 'tableAlias']);
}
/**
* Add method
*
* @return mixed Redirects on successful add, renders view otherwise.
*/
public function add()
{
$table = $this->loadModel();
$tableAlias = $table->getAlias();
$entity = $table->newEntity([]);
$this->set($tableAlias, $entity);
$this->set('tableAlias', $tableAlias);
$this->set('_serialize', [$tableAlias, 'tableAlias']);
if (!$this->getRequest()->is('post')) {
return;
}
$entity = $table->patchEntity($entity, $this->getRequest()->getData());
$singular = Inflector::singularize(Inflector::humanize($tableAlias));
if ($table->save($entity)) {
$this->Flash->success(__d('cake_d_c/users', 'The {0} has been saved', $singular));
return $this->redirect(['action' => 'index']);
}
$this->Flash->error(__d('cake_d_c/users', 'The {0} could not be saved', $singular));
}
/**
* Edit method
*
* @param string|null $id User id.
* @return mixed Redirects on successful edit, renders view otherwise.
* @throws \Cake\Http\Exception\NotFoundException When record not found.
*/
public function edit($id = null)
{
$table = $this->loadModel();
$tableAlias = $table->getAlias();
$entity = $table->get($id, [
'contain' => [],
]);
$this->set($tableAlias, $entity);
$this->set('tableAlias', $tableAlias);
$this->set('_serialize', [$tableAlias, 'tableAlias']);
if (!$this->getRequest()->is(['patch', 'post', 'put'])) {
return;
}
$entity = $table->patchEntity($entity, $this->getRequest()->getData());
$singular = Inflector::singularize(Inflector::humanize($tableAlias));
if ($table->save($entity)) {
$this->Flash->success(__d('cake_d_c/users', 'The {0} has been saved', $singular));
return $this->redirect(['action' => 'index']);
}
$this->Flash->error(__d('cake_d_c/users', 'The {0} could not be saved', $singular));
}
/**
* Delete method
*
* @param string|null $id User id.
* @return \Cake\Http\Response Redirects to index.
* @throws \Cake\Http\Exception\NotFoundException When record not found.
*/
public function delete($id = null)
{
$this->getRequest()->allowMethod(['post', 'delete']);
$table = $this->loadModel();
$tableAlias = $table->getAlias();
$entity = $table->get($id, [
'contain' => [],
]);
$singular = Inflector::singularize(Inflector::humanize($tableAlias));
if ($table->delete($entity)) {
$this->Flash->success(__d('cake_d_c/users', 'The {0} has been deleted', $singular));
} else {
$this->Flash->error(__d('cake_d_c/users', 'The {0} could not be deleted', $singular));
}
return $this->redirect(['action' => 'index']);
}
}