/var/www/vhosts/ihelp.ro/httpdocs/src/Controller
Edit: /var/www/vhosts/ihelp.ro/httpdocs/src/Controller/DonationsController.php (2969B)
paginate = [
'contain' => ['Users', 'Causes', 'Orders'],
];
$donations = $this->paginate($this->Donations);
$this->set(compact('donations'));
}
/**
* View method
*/
public function view($id = null)
{
$donation = $this->Donations->get($id, [
'contain' => ['Users', 'Causes', 'Orders', 'PaymentLogs'],
]);
$this->set(compact('donation'));
}
/**
* Add method
*/
public function add()
{
$donation = $this->Donations->newEmptyEntity();
if ($this->request->is('post')) {
$donation = $this->Donations->patchEntity($donation, $this->request->getData());
if ($this->Donations->save($donation)) {
$this->Flash->success(__('The donation has been saved.'));
return $this->redirect(['action' => 'index']);
}
$this->Flash->error(__('The donation could not be saved. Please, try again.'));
}
$users = $this->Donations->Users->find('list', ['limit' => 200]);
$causes = $this->Donations->Causes->find('list', ['limit' => 200]);
$orders = $this->Donations->Orders->find('list', ['limit' => 200]);
$this->set(compact('donation', 'users', 'causes', 'orders'));
}
/**
* Edit method
*/
public function edit($id = null)
{
$donation = $this->Donations->get($id, [
'contain' => [],
]);
if ($this->request->is(['patch', 'post', 'put'])) {
$donation = $this->Donations->patchEntity($donation, $this->request->getData());
if ($this->Donations->save($donation)) {
$this->Flash->success(__('The donation has been saved.'));
return $this->redirect(['action' => 'index']);
}
$this->Flash->error(__('The donation could not be saved. Please, try again.'));
}
$users = $this->Donations->Users->find('list', ['limit' => 200]);
$causes = $this->Donations->Causes->find('list', ['limit' => 200]);
$orders = $this->Donations->Orders->find('list', ['limit' => 200]);
$this->set(compact('donation', 'users', 'causes', 'orders'));
}
/**
* Delete method
*/
public function delete($id = null)
{
$this->request->allowMethod(['post', 'delete']);
$donation = $this->Donations->get($id);
if ($this->Donations->delete($donation)) {
$this->Flash->success(__('The donation has been deleted.'));
} else {
$this->Flash->error(__('The donation could not be deleted. Please, try again.'));
}
return $this->redirect(['action' => 'index']);
}
}