/** * Synchronize template blocks. * * @param Template $template * @param [type] $xmlBlock * * @return void */ protected static function syncTemplateBlock(Template $template, $xmlBlock) { $blockIdentifier = (string) $xmlBlock->attributes->identifier; $blockTitle = (string) $xmlBlock->attributes->title; $blockIdentifier = str_slug($blockIdentifier); $block = $template->blocks()->whereIdentifier($blockIdentifier)->first(); if ($block) { $block->title = $blockTitle; $block->save(); } else { $template->blocks()->create(['identifier' => $blockIdentifier, 'title' => $blockTitle]); } }
public function generateTemplatesFile() { $templates = Template::all(); foreach ($templates as $template) { $this->generateTemplateFile($template); } }
protected function create($name, $shortcut, $description, $is_home) { return Page::create(['name' => $name, 'shortcut' => $shortcut, 'description' => $description, 'is_home' => $is_home, 'template_id' => Template::first()->id]); }
/** * Set new template to a page. * * @param Page $page * @param SwitchTemplateRequest $request * * @return array */ public function switchTemplate(Page $page, SwitchTemplateRequest $request) { $connectedBlocks = $this->blocksAreConnected($page, $request->get('connected_blocks')); $template = Template::findOrFail($request->get('template_id')); $page->template()->associate($template)->save(); $this->updateTemplateBlocks($page, $request->get('connected_blocks')); event(new PageTemplateWasSwitched($page)); $url = route('zxadmin.page.edit', [$page->id, $page->template->blocks()->firstOrFail()->identifier]); return ['connectedBlocks' => $connectedBlocks, 'template' => $template, 'url' => $url]; }
protected function create($templateIdentifier, $name, $type, $shortcut, $description) { return Page::create(['name' => $name, 'type' => $type, 'shortcut' => $shortcut, 'description' => $description, 'template_id' => Template::whereIdentifier($templateIdentifier)->first()->id]); }
/** * Define your route model bindings, pattern filters, etc. * * @param \Illuminate\Routing\Router $router * * @return void */ public function boot(Router $router) { $router->bind('adWithTrashed', function ($id) { return Ad::with('content')->withTrashed()->findOrFail($id); }); $router->bind('ad', function ($id) { return Ad::with('content')->findOrFail($id); }); $router->bind('adCollection', function ($ids) { $ids = explode(',', $ids); return Ad::with('content')->withTrashed()->findMany($ids); }); $router->bind('adstatus', function ($title) { return Adstatus::whereTitle($title)->firstOrFail(); }); $router->bind('adValidated', function ($id) { return Ad::with('content')->validate()->findOrFail($id); }); $router->bind('adPreview', function ($id) { if (Auth::guard('admin')->check()) { return Ad::with('content')->withTrashed()->findOrFail($id); } if (Auth::guard('user')->check()) { return Auth::user()->ads()->with('content')->findOrFail($id); } abort(404); }); $router->bind('adtypeNotCustomized', function ($id) { return Adtype::whereIsCustomized(0)->findOrFail($id); }); $router->bind('adtypeCollection', function ($ids) { $ids = explode(',', $ids); return Adtype::findMany($ids); }); $router->bind('templateCollection', function ($ids) { $ids = explode(',', $ids); return Template::findMany($ids); }); $router->bind('encryptedOrderId', function ($enc) { $orderId = Crypt::decrypt($enc); return Order::findOrFail($orderId); }); $router->bind('fieldCollection', function ($ids) { $ids = explode(',', $ids); return Field::findMany($ids); }); $router->bind('subscriptionCollection', function ($ids) { $ids = explode(',', $ids); return Subscription::findMany($ids); }); $router->bind('userCollection', function ($ids) { $ids = explode(',', $ids); return User::findMany($ids); }); $router->bind('adUser', function ($id) { if (Auth::check()) { return Auth::user()->ads()->with('content')->findOrFail($id); } else { abort(404); } }); $router->bind('field', function ($id) { return Field::with('search')->findOrFail($id); }); $router->bind('visibleCategory', function ($id) { return Category::visible()->findOrFail($id); }); $router->bind('templateblock', function ($identifier) use($router) { $page = $router->input('page'); return Templateblock::whereIdentifier($identifier)->whereTemplateId($page->template->id)->firstOrFail(); }); $router->bind('widgetnode', function ($id) use($router) { $pageId = $router->input('page')->id; $templateblockId = $router->input('templateblock')->id; return Widgetnode::whereTemplateblockId($templateblockId)->wherePageId($pageId)->findOrFail($id); }); $router->model('adtype', 'ZEDx\\Models\\Adtype'); $router->model('template', 'ZEDx\\Models\\Template'); $router->model('category', 'ZEDx\\Models\\Category'); $router->model('country', 'ZEDx\\Models\\Country'); $router->model('page', 'ZEDx\\Models\\Page'); $router->model('menu', 'ZEDx\\Models\\Menu'); $router->model('gateway', 'ZEDx\\Models\\Gateway'); $router->model('themepartial', 'ZEDx\\Models\\Themepartial'); $router->model('dashboardWidget', 'ZEDx\\Models\\Dashboardwidget'); $router->model('searchfield', 'ZEDx\\Models\\SearchField'); $router->model('selectfield', 'ZEDx\\Models\\SelectField'); $router->model('subscription', 'ZEDx\\Models\\Subscription'); $router->model('user', 'ZEDx\\Models\\User'); parent::boot($router); }
/** * set a new active Theme. * * @param string $theme * * @return bool */ public function setActive($theme) { if (!$this->exists($theme)) { throw new Exception("Theme {$theme} doesn't exist!"); } umask(0); $this->cleanActiveTheme(); $themePath = base_path('themes' . DIRECTORY_SEPARATOR . $theme); @symlink($themePath . '/task.js', base_path('tasks/frontend.js')); @symlink($themePath . '/widgets', base_path('widgets/Frontend/Theme')); env_replace('APP_FRONTEND_THEME', $theme); $this->saveThemePartials(); if (Template::all()->isEmpty()) { TemplateHelper::saveTemplates($theme); } Artisan::call('theme:publish', ['--force' => true]); }
/** * Remove the specified resource from storage. * * @param Template $template * * @return Response */ protected function destroy(Template $template) { $template->delete(); }