/**
  * Method for upload files
  *
  * @param Request $request
  * @param MediaRepositoryInterface $repositoryInterface
  * @return string
  */
 public function upload(Request $request, MediaRepositoryInterface $repositoryInterface)
 {
     \Debugbar::disable();
     $id = $repositoryInterface->create($request->file('file'), null, null);
     $answer = array('answer' => 'File transfer completed', 'id' => $id);
     $json = json_encode($answer);
     return $json;
 }
예제 #2
0
 /**
  * Delete News
  *
  * @param $id
  * @return mixed
  */
 public function delete($id)
 {
     $news = News::findOrFail($id);
     $deletedTranlation = $this->translationRepositoryInterface->delete('news', $id);
     $deletedMedias = $this->mediaRepositoryInterface->deleteByTable('news', $id);
     return $deletedTranlation && $deletedMedias ? $news->delete() : false;
 }
예제 #3
0
 /**
  * Update Spec
  *
  * @param $id
  * @param $category
  * @param $name
  * @param $descriptions
  * @param $addImage
  * @param $removeImage
  * @return mixed
  */
 public function update($id, $category, $name, $descriptions, $addImage, $removeImage)
 {
     $category = Category::findOrFail($category);
     $spec = Spec::findOrFail($id);
     try {
         $spec->category_id = $category->id;
         $spec->name = strtolower($name);
         $spec->save();
         //cria as traduções
         foreach ($descriptions as $iso => $value) {
             $lang = Lang::whereIso($iso)->first();
             $this->translationRepositoryInterface->update($lang->id, 'specs', $spec->id, $value);
         }
         //adiciona novas imagens
         if (!empty($addImage)) {
             $this->mediaRepositoryInterface->updateTable($addImage, 'specs', $spec->id);
         }
         if (!empty($removeImage)) {
             $this->mediaRepositoryInterface->deleteById($removeImage);
         }
     } catch (\Exception $e) {
         \Log::error($e);
         return false;
     }
     return true;
 }
 /**
  * Delete Spec
  *
  * @param $id
  * @return mixed
  */
 public function delete($id)
 {
     $support = Support::findOrFail($id);
     $deletedMedias = $this->mediaRepositoryInterface->deleteByTable('supports', $id);
     return $deletedMedias ? $support->delete() : false;
 }