/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/GalleryImagesController.php (3246B)
BasicGalleryImages > Upload # -------------------------------- public function upload($model, $foreignKey, $foreignUuid) { $this->autoRender = false; $galleryImage = $this->GalleryImages->newEmptyEntity(); if ($this->request->is('post')) { $galleryImage = $this->GalleryImages->patchEntity($galleryImage, $this->request->getData()); $existFeatured = $this->GalleryImages->find() ->where(['GalleryImages.foreign_uuid' => $foreignUuid, 'GalleryImages.is_featured' => true]) ->toArray(); if (empty($existFeatured)) { $galleryImage->is_featured = true; } $galleryImage->foreign_key = $foreignKey; $galleryImage->model = $model; $galleryImage->foreign_uuid = $foreignUuid; if ($this->GalleryImages->save($galleryImage)) { die(); } else { die('Error'); } } } # Delete photos public function delete($id = null) { if (!empty($id)) { $this->request->allowMethod(['post', 'delete', 'put', 'get']); $galleryImage = $this->GalleryImages->get($id); $imagePath = new File(WWW_ROOT . $galleryImage->image_path); if ($this->GalleryImages->delete($galleryImage)) { # Delete the files $imagePath->delete(); $this->Flash->success(__('Imaginea a fost ștearsă.')); } else { $this->Flash->error(__('Imaginea nu au putut fi ștearsă. Vă rugăm să încercați din nou.')); } } else { } return $this->redirect($this->referer()); } # setFeaturedImage public function setFeaturedImage($foreignKey = null, $model = null, $imageId = null) { $this->viewBuilder()->setLayout('ajax'); $this->autoRender = false; if (!empty($imageId)) { if ($this->request->is('post')) { $this->GalleryImages->updateAll( [ // fields 'is_featured' => false, ], [ // conditions 'GalleryImages.foreign_key' => $foreignKey, 'GalleryImages.model' => $model, ] ); $this->GalleryImages->id = $imageId; if ($this->GalleryImages->saveField('is_featured', true)) { $this->Flash->success(__('Imaginea principală a fost salvată.')); } else { $this->Flash->error(__('Imaginea principală nu a putut fi salvată. Vă rugăm să încercați din nou.')); } } } else { $this->Flash->error(__('A apărut o problemă. Vă rugăm să încercați din nou')); } return $this->redirect($this->referer()); } }