/var/www/vhosts/ihelp.ro/httpdocs/src/Controller/Dashboard
NameSizeModeActions
DashboardController.php21390644editdlrm
GalleryImagesController.php36690644editdlrm
OrdersController.php38060644editdlrm
ProductFavoritesController.php65610644editdlrm
ProductsController.php63100644editdlrm
ProfilesController.php34670644editdlrm
UserAddressesController.php50090644editdlrm
UsersController.php24020644editdlrm
Edit: /var/www/vhosts/ihelp.ro/httpdocs/src/Controller/Dashboard/GalleryImagesController.php (3669B)
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)) { $responses['status'] = 200; $responses['message'] = 'Success.The image has been saved.'; } else { $responses['status'] = 400; $responses['errors'] = $galleryImage->getErrors(); $responses['message'] = 'Error. The quiz could not be saved. Please, try again.'; } $this->set(compact('responses')); $this->viewBuilder()->setOption('serialize', ['responses']); $this->RequestHandler->renderAs($this, 'json'); } } /** * delete method */ 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 method */ 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()); } }