/**
  * 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;
 }
 /**
  * Update Spec
  *
  * @param $id
  * @param $category
  * @param $name
  * @param $lang
  * @param $file
  * @return mixed
  */
 public function update($id, $category, $name, $lang, $file)
 {
     $category = Category::findOrFail($category);
     $lang = Lang::findOrFail($lang);
     $support = Support::findOrFail($id);
     try {
         $support->category_id = $category->id;
         $support->name = strtolower($name);
         $support->lang_id = $lang->id;
         $support->save();
         if (!is_null($file)) {
             $this->mediaRepositoryInterface->deleteByTable('supports', $id);
             $this->mediaRepositoryInterface->create($file, 'supports', $support->id);
         }
     } catch (\Exception $e) {
         \Log::error($e);
         if (!is_null($support) && $support->exists) {
             $this->delete($support->id);
         }
         return false;
     }
     return true;
 }