protected function loadPost()
 {
     $post = PerformanceModel::isPublished()->Performance()->whereSlug($this->slug)->first();
     /*
      * Add a "URL" helper attribute for linking to each performance and person press
      */
     $this->roles = [];
     $this->participation = [];
     $post->participation->each(function ($role) {
         $role->person->setUrl($this->personPage, $this->controller);
         if ($role['group'] != null) {
             $this->roles[$role['group']][] = $role;
             return;
         }
         $this->participation[$role['title']]['title'] = $role->title;
         $this->participation[$role['title']]['type'] = $role->type;
         $this->participation[$role['title']]['description'] = $role->description;
         $this->participation[$role['title']]['group'] = $role->group;
         $this->participation[$role['title']]['persons'][] = $role->person;
     });
     $post->press->each(function ($press) {
         $press->setUrl($this->pressPage, $this->controller);
     });
     // ROLES
     $post->roles = $this->roles;
     $post->roles_ng = $this->participation;
     CW::info(['Performance' => $post]);
     return $post;
 }
Esempio n. 2
0
 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 findPerformance($name)
 {
     $post = Performance::where('title', '=', $name)->first();
     // echo "\n\n\n  " . mb_convert_encoding($name, "CP866") . ": " . $post->id . "\n\n";
     return $post;
 }