/var/www/vhosts/ihelp.ro/httpdocs/src/Controller/Admin
Edit: /var/www/vhosts/ihelp.ro/httpdocs/src/Controller/Admin/ProposedCausesController.php (3339B)
paginate($this->ProposedCauses);
$this->set(compact('proposedCauses'));
}
/**
* View method
*/
public function view($id = null)
{
$proposedCause = $this->ProposedCauses->get($id, [
'contain' => [],
]);
$this->set(compact('proposedCause'));
}
/**
* Edit method
*/
public function edit($id = null)
{
$this->loadModel('Causes');
if ($this->request->is(['patch', 'post', 'put'])) {
$proposedCause = $this->ProposedCauses->find()
->where(['id' => $id])
->first();
$satusProposedCause = $proposedCause->is_contacted;
$proposedCause->is_contacted = ($satusProposedCause) ? false : true;
$proposedCause = $this->ProposedCauses->patchEntity($proposedCause, $this->request->getData());
if ($this->ProposedCauses->save($proposedCause)) {
$this->Flash->success(__('The proposed cause has been saved.'));
$cause = $this->Causes->find()
->where(['Causes.uuid' => $proposedCause->uuid])
->first();
if (empty($cause)) {
$newCause = $this->Causes->newEmptyEntity();
$newCause->name = $proposedCause->cause_name;
$newCause->donation_amount = $proposedCause->donation_amount;
$newCause->description = $proposedCause->description;
$newCause->user_id = $this->request->getSession()->read('Auth.id');
if ($this->Causes->save($newCause, ['validate' => false])) {
$newCause->uuid = $proposedCause->uuid;
$this->Causes->save($newCause);
$this->Flash->success(__('The new cause has been saved.'));
return $this->redirect(['prefix' => 'Admin', 'controller' => 'Causes', 'action' => 'edit', $newCause->id]);
} else {
$this->Flash->error(__('The new cause could not be saved. Please, try again.'));
}
}
return $this->redirect(['prefix' => 'Admin', 'controller' => 'ProposedCauses', 'action' => 'index']);
}
$this->Flash->error(__('The proposed cause could not be saved. Please, try again.'));
}
}
/**
* Delete method
*/
public function delete($id = null)
{
$this->request->allowMethod(['post', 'delete']);
$proposedCause = $this->ProposedCauses->get($id);
if ($this->ProposedCauses->delete($proposedCause)) {
$this->Flash->success(__('The proposed cause has been deleted.'));
} else {
$this->Flash->error(__('The proposed cause could not be deleted. Please, try again.'));
}
return $this->redirect(['prefix' => 'Admin', 'controller' => 'ProposedCauses', 'action' => 'index']);
}
}