/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($projectFileId, $id) { if ($this->checkProjectOwner($id) == false) { return ['error' => 'Acesso Negado']; } if ($file = ProjectFile::find($id) == null) { return "arquivo não existe"; } $this->service->removeProjecFile($id); //return $file->id.".".$file->extension; //$filename = Input::get('id'); //$extension = Input::get('extension'); //if(!Storage::delete($file->id+.+file->extension)){ // Session::flash('fash_message', 'Error'); //}else { // $file->delete(); //} }
public function removeProjecFile($id) { $file = ProjectFile::find($id); try { \Illuminate\Support\Facades\Storage::delete($file->id . "." . $file->extension); ProjectFile::destroy($id); } catch (ValidatorException $e) { return ['error' => true, 'message' => $e->getMessageBag()]; } }