protected function loadPost() { $post = PersonModel::isPublished()->with(['portrait', 'participation.performance', 'featured'])->whereSlug($this->slug)->first(); $post->participation->each(function ($participation) { $participation->performance->setUrl($this->performancePage, $this->controller); if ($participation->type == 'roles') { $this->roles[$participation->performance->id]['url'] = $participation->performance->url; $this->roles[$participation->performance->id]['performance'] = $participation->performance->title; $this->roles[$participation->performance->id]['author'] = $participation->performance->author; $this->roles[$participation->performance->id]['roles'][] = $participation->title; } }); $post['roles'] = $this->roles; if ($post->portrait) { $image = $post->portrait; $image['thumb'] = $image->getThumb(250, 250, 'crop'); } // $post->relation->each(function($relation){ // $relation->setUrl($this->relationPage, $this->controller); // }); CW::info(['post' => $post]); return $post; }
public function boot() { // App::register( 'Laravelrus\LocalizedCarbon\LocalizedCarbonServiceProvider' ); $alias = AliasLoader::getInstance(); // $alias->alias( 'LocalizedCarbon', 'Laravelrus\LocalizedCarbon\LocalizedCarbon' ); // $alias->alias( 'DiffFormatter' , 'Laravelrus\LocalizedCarbon\DiffFactoryFacade' ); $alias->alias('Carbon', '\\Carbon\\Carbon'); $alias->alias('CW', '\\Clockwork\\Support\\Laravel\\Facade'); /* * Register menu items for the RainLab.Pages plugin */ Event::listen('pages.menuitem.listTypes', function () { return ['repertoire' => 'Репертуар', 'troupe' => 'Труппа', 'playbill' => 'Афиша']; }); Event::listen('pages.menuitem.getTypeInfo', function ($type) { if ($type == 'repertoire') { return PerformanceModel::getMenuTypeInfo($type); } if ($type == 'troupe') { return PersonModel::getMenuTypeInfo($type); } if ($type == 'playbill') { return EventModel::getMenuTypeInfo($type); } }); Event::listen('pages.menuitem.resolveItem', function ($type, $item, $url, $theme) { if ($type == 'repertoire') { return PerformanceModel::resolveMenuItem($item, $url, $theme); } if ($type == 'troupe') { return PersonModel::resolveMenuItem($item, $url, $theme); } if ($type == 'playbill') { return EventModel::resolveMenuItem($item, $url, $theme); } }); }
private function createPerson($name) { // echo "Create post: " . mb_convert_encoding($name, "CP866") . "\n"; $data = ['family_name' => explode(' ', $name)[1], 'given_name' => explode(' ', $name)[0]]; $post = Person::create($data); return $post; }