/var/www/vhosts/ihelp.ro/httpdocs/src/Controller/Admin
Edit: /var/www/vhosts/ihelp.ro/httpdocs/src/Controller/Admin/CauseNewsController.php (2145B)
paginate = [
'contain' => ['Causes'],
];
$causeNews = $this->paginate($this->CauseNews);
$this->set(compact('causeNews'));
}
/**
* View method
*/
public function view($id = null)
{
$causeNews = $this->CauseNews->get($id, [
'contain' => ['Causes'],
]);
$this->set(compact('causeNews'));
}
/**
* Add method
*/
public function add()
{
$causeNews = $this->CauseNews->newEmptyEntity();
if ($this->request->is('post')) {
$causeNews = $this->CauseNews->patchEntity($causeNews, $this->request->getData());
if ($this->CauseNews->save($causeNews)) {
$this->Flash->success(__('The cause news has been saved.'));
return $this->redirect(['action' => 'index']);
}
$this->Flash->error(__('The cause news could not be saved. Please, try again.'));
}
$causes = $this->CauseNews->Causes->find('list', ['limit' => 200]);
$this->set(compact('causeNews', 'causes'));
}
/**
* Edit method
*/
public function edit($id = null)
{
$causeNews = $this->CauseNews->get($id, [
'contain' => [],
]);
if ($this->request->is(['patch', 'post', 'put'])) {
$causeNews = $this->CauseNews->patchEntity($causeNews, $this->request->getData());
if ($this->CauseNews->save($causeNews)) {
$this->Flash->success(__('The cause news has been saved.'));
return $this->redirect(['action' => 'index']);
}
$this->Flash->error(__('The cause news could not be saved. Please, try again.'));
}
$causes = $this->CauseNews->Causes->find('list', ['limit' => 200]);
$this->set(compact('causeNews', 'causes'));
}
}