/** * Update given project in database. * * @param array $project * @return Project|boolean */ public function update(array $input) { $project = $input['project']; //if project with this id doesn't exist - bail if (!$this->project->find($project['id'])) { return false; } if (isset($input['template'])) { $this->deletePages($project['id']); $project = $this->useTemplate(Project::find($project['id']), $input['template']); } else { $this->updatePages($project); } $p = $this->project->with('pages.libraries')->find($project['id']); $p->touch(); return $p->toArray(); }
/** * Create export zip file for given project. * * @param string/int $id * @param boolean $zip * * @return boolean/string */ public function project($id, $zip = true) { $project = $this->project->find($id); //bail if no project found if (!$project) { return false; } //bail if project not public and doesn't belong to current user if (!$project->public) { if (!$project->users()->where('users.id', $this->app['sentry']->getUser()->id)->first()) { return false; } } if ($path = $this->createFolders($project)) { $this->createFiles($path, $project); if ($zip) { return $this->zip($path, $project->id); } return $path; } }