public function seedDemoProjects() { $templates = Template::limit(8)->get(); foreach ($templates as $k => $template) { $name = 'Demo-' . ($k + 1); $this->projectCreator->create(array('name' => $name, 'template' => $template->id, 'public' => 1)); } }
/** * Use given template for given project. * * @param ProjectModel $project * @param integer $templateId * * @return ProjectModel */ private function useTemplate(Project $project, $templateId) { $template = Template::with('pages')->find($templateId); $pages = array(); foreach ($template->pages as $page) { $pages[] = new Page(array_except($page->toArray(), array('id', 'pageable_id', 'pageable_type', 'created_at', 'updated_at'))); } $project->pages()->saveMany($pages); $this->attachLibraries($project); //copy thumbnail from template to project $path = $this->app['base_dir'] . '/' . $template->thumbnail; $this->fs->copy($path, $this->app['base_dir'] . '/assets/images/projects/project-' . $project->id . '.png', true); return $project; }