repo = $repo; } public function repoGetData(){ return $this->repo->get(); } public function repoSave($data){ if($data['file']){ $path = $this->uploadImage($data['file']); $data['logo'] = $path; } return $this->repo->save($data); } public function repoUpdate($id,$data){ return $this->repo->update($id, $data); } public function repoGetDataByID($id){ return $this->repo->getById($id); } public function repoDeleteById($id) { return $this->repo->delete($id); } public function uploadImage($image){ $check = in_array($image->extension(), $this->allowedFileExtension); if($check){ $filename = $image->getClientOriginalName(); $path = $image->move(public_path($this->path), $filename); return $path->getPathName(); }else{ throw ValidationException::withMessages(['file' => 'Wrong file extension']); } } }