/** * @internal param $generatedRecords */ private function createMenuEntry() { $records = \Modules\Page\Entities\Page::where('published', 1)->take(3)->get(); if ($main = Menu::root()->where(['name' => 'Main'])->first()) { foreach ($records as $element) { $main->children()->create(['name' => $element['title'], 'url' => "page/{$element['slug']}", 'active' => true]); } } }
/** * Handle the event. * * @param PageWasCreated $event */ public function pageHandle($event) { $page = Page::firstOrNew(['id' => $event->pageId]); $this->saveDynamicData($page, $event->data); }
/** * Handle the event. * * @param PageWasUpdated $event */ public function pageHandle($event) { $page = Page::find($event->pageId); $this->saveDynamicData($page, $event->data); }