public function destroyImage($id) { try { $image = $this->repositoryFile->skipPresenter()->find($id); if (count($image)) { // dd($this->storage->disk('local')->exists($image->id)); if ($this->storage->exists($image->id . '.' . $image->extension)) { $this->storage->delete($image->id . '.' . $image->extension); } else { return ['error' => true, 'message' => 'file does not exist']; } $image->delete(); return ['sucess' => true, 'message' => 'image deleted']; } } catch (ModelNotFoundException $e) { return ['error' => true, 'message' => 'image not found']; } }
public function createFile(array $data) { $project = $this->repository->skipPresenter()->find($data['project_id']); $projectFile = $project->files()->create($data); $this->storage->put($projectFile->id . "." . $data['extension'], $this->filesystem->get($data['file'])); }