/var/www/vhosts/ihelp.ro/httpdocs/src/Controller/Admin
Edit: /var/www/vhosts/ihelp.ro/httpdocs/src/Controller/Admin/SettingsController.php (3157B)
paginate = [
'limit' => ADMIN_PAGE_LIMIT
];
$settings = $this->paginate($this->Settings);
$this->set(compact('settings'));
}
/**
* View method
*/
public function view($id = null)
{
$setting = $this->Settings->get($id, [
'contain' => [],
]);
$this->set(compact('setting'));
}
/**
* Add method
*/
public function add()
{
$setting = $this->Settings->newEmptyEntity();
if ($this->request->is('post')) {
$setting = $this->Settings->patchEntity($setting, $this->request->getData());
if ($this->Settings->save($setting)) {
$this->Flash->success(__('The setting has been saved.'));
return $this->redirect(['prefix' => 'Admin', 'controller' => 'Settings', 'action' => 'index']);
}
$this->Flash->error(__('The setting could not be saved. Please, try again.'));
}
$types = Configure::read('type_settings');
$this->set(compact('setting', 'types'));
}
/**
* Edit method
*/
public function edit($id = null)
{
if (!empty($id) && is_numeric($id)) {
$setting = $this->Settings->get($id, [
'contain' => [],
]);
if ($this->request->is(['patch', 'post', 'put'])) {
$setting = $this->Settings->patchEntity($setting, $this->request->getData());
if ($this->Settings->save($setting)) {
$this->Flash->success(__('The setting has been saved.'));
return $this->redirect(['prefix' => 'Admin', 'controller' => 'Settings', 'action' => 'edit', $id]);
}
$this->Flash->error(__('The setting could not be saved. Please, try again.'));
}
} else {
$this->Flash->error(__('Oops. Please, try again.'));
return $this->redirect(['prefix' => 'Admin', 'controller' => 'Settings', 'action' => 'index']);
}
$types = Configure::read('type_settings');
$this->set(compact('setting', 'types'));
}
/**
* Delete method
*/
public function delete($id = null)
{
if (!empty($id) && is_numeric($id)) {
$this->request->allowMethod(['post', 'delete']);
$setting = $this->Settings->get($id);
if ($this->Settings->delete($setting)) {
$this->Flash->success(__('The setting has been deleted.'));
} else {
$this->Flash->error(__('The setting could not be deleted. Please, try again.'));
}
} else {
$this->Flash->error(__('Oops. Please, try again.'));
}
return $this->redirect(['prefix' => 'Admin', 'controller' => 'Settings', 'action' => 'index']);
}
}