public function createFile(array $data) { $project = $this->repository->skipPresenter()->find($data['project_id']); // dd($project); $projectFile = $project->files()->create($data); $this->storage->put($projectFile->id . "." . $data['extension'], $this->filesystem->get($data['file'])); }
/** * @param $id * @param array $with * @return array|mixed */ public function show($id, $with = []) { try { return $this->repository->skipPresenter()->with($with)->find($id); } catch (ModelNotFoundException $e) { return ['error' => true, 'message' => 'No data found for id:' . $id]; } }
public function destroy($id) { try { $this->repository->skipPresenter()->find($id)->delete(); return ['deleted' => 'true']; } catch (ModelNotFoundException $e) { return ['error' => true, 'message' => 'No data found for id:' . $id]; } catch (QueryException $e) { return ['error' => true, 'message' => 'You cannot delete this data, there is register related!']; } }