/var/www/vhosts/ihelp.ro/httpdocs/src/Controller/Admin
NameSizeModeActions
AdminController.php57720644editdlrm
BankAccountsController.php31440644editdlrm
BannersController.php45400644editdlrm
CategoriesController.php44980644editdlrm
CauseNewsController.php21450644editdlrm
CausesController.php87590644editdlrm
CronsController.php18000644editdlrm
DashboardController.php10620644editdlrm
DocumentsController.php36490644editdlrm
DonationsController.php5590644editdlrm
GalleryImagesController.php32460644editdlrm
OrdersController.php44760644editdlrm
ProductsController.php56420644editdlrm
ProposedCausesController.php33390644editdlrm
SettingsController.php31570644editdlrm
SponsorsActivitiesController.php40030644editdlrm
SponsorsController.php36470644editdlrm
TagsController.php26520644editdlrm
UsersController.php82440644editdlrm
Edit: /var/www/vhosts/ihelp.ro/httpdocs/src/Controller/Admin/BannersController.php (4540B)
paginate = [ 'limit' => ADMIN_PAGE_LIMIT, 'conditions' => $conditions, 'sortableFields' => ['Banners.id', 'Banners.name', 'Banners.is_active', 'Banners.created'] ]; $banners = $this->paginate($this->Banners); $positions = $this->Banners->find() ->select(['position', 'position']) ->all(); $positionList = Hash::combine($positions->toArray(), '{n}.position', '{n}.position'); $positionList = [null => __('All')] + $positionList; $this->set(compact('banners', 'positionList')); } /** * View method * * @param string|null $id Banner id. * @return \Cake\Http\Response|null|void Renders view * @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found. */ public function view($id = null) { $banner = $this->Banners->get($id, [ 'contain' => [], ]); $this->set(compact('banner')); } /** * Add method * * @return \Cake\Http\Response|null|void Redirects on successful add, renders view otherwise. */ public function add() { $banner = $this->Banners->newEmptyEntity(); if ($this->request->is('post')) { $data = $this->request->getData(); $image = $data['image_path']; $name = $image->getClientFilename(); $image->moveTo(WWW_ROOT . 'img' . DS . $name); $data['image_path'] = $name; $banner = $this->Banners->patchEntity($banner, $data); if ($this->Banners->save($banner)) { $this->Flash->success(__('The banner has been saved.')); return $this->redirect(['prefix' => 'Admin', 'controller' => 'Banners', 'action' => 'index']); } $this->Flash->error(__('The banner could not be saved. Please, try again.')); } $this->set(compact('banner')); } /** * Edit method * * @param string|null $id Banner id. * @return \Cake\Http\Response|null|void Redirects on successful edit, renders view otherwise. * @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found. */ public function edit($id = null) { $banner = $this->Banners->get($id); if ($this->request->is(['patch', 'post', 'put'])) { $data = $this->request->getData(); $image = $data['image_path']; if ($image->getError() == 0) { $data = $this->request->getData(); $image = $data['image_path']; $name = $image->getClientFilename(); $image->moveTo(WWW_ROOT . 'img' . DS . $name); $data['image_path'] = $name; } else { unset($data['image_path']); } $banner = $this->Banners->patchEntity($banner, $data); if ($this->Banners->save($banner)) { $this->Flash->success(__('The banner has been saved.')); return $this->redirect(['prefix' => 'Admin', 'controller' => 'Banners', 'action' => 'index']); } $this->Flash->error(__('The banner could not be saved. Please, try again.')); } $this->set(compact('banner')); } /** * Delete method * * @param string|null $id Banner id. * @return \Cake\Http\Response|null|void Redirects to index. * @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found. */ public function delete($id = null) { $this->request->allowMethod(['post', 'delete']); $banner = $this->Banners->get($id); if ($this->Banners->delete($banner)) { $this->Flash->success(__('The banner has been deleted.')); } else { $this->Flash->error(__('The banner could not be deleted. Please, try again.')); } return $this->redirect(['action' => 'index']); } }