/** * Attach libraries from given template pages to given projects pages. * * @param Project $project * @param Template $template * * @return void */ private function attachLibraries(Project $project) { foreach ($project->pages as $page) { if ($page->libraries && ($libs = json_decode($page->libraries, true))) { $ids = Library::whereIn('name', $libs)->lists('id'); $page->libraries()->attach($ids); } } }
/** * Cope any local js libraries to export folder. * * @param string $libraries * @param string $path * * @return string scripts html to insert before closing body tag */ private function handleLibraries($libraries, $path) { $scripts = "<script src=\"js/jquery.js\"></script>\n<script src=\"js/bootstrap.js\"></script>\n"; @$this->fs->copy($this->app['base_dir'] . '/assets/js/vendor/jquery.js', $path . 'js/jquery.js', true); @$this->fs->copy($this->app['base_dir'] . '/assets/js/vendor/bootstrap/bootstrap.min.js', $path . 'js/bootstrap.js', true); $libraries = json_decode($libraries); if ($libraries) { foreach ($libraries as $library) { if (is_string($library)) { $library = Library::where('name', $library)->first(); } if (!str_contains($library->path, '//')) { $absolute = $this->relativeToAbsolute($library->path); try { @$this->fs->copy($absolute, $path . 'js/' . basename($absolute), true); } catch (\Exception $e) { continue; } $scripts .= '<script src="js/' . basename($library->path) . "\"></script>\n"; } else { $scripts .= '<script src="' . $library->path . "\"></script>\n"; } } } return $scripts; }