/**
  * Bootstrap the application services.
  *
  * @return void
  */
 public function boot()
 {
     \View::composer('includes.header', function ($view) {
         $pages = array('AboutUs' => array('route' => 'about-us', 'name' => 'About Us'), 'WhatsOn' => array('route' => 'whats-on', 'name' => 'What\'s On'), 'FindUs' => array('route' => 'find-us', 'name' => 'Find Us'), 'ContactUs' => array('route' => 'contact-us', 'name' => 'Contact Us'), 'Sermons' => array('route' => 'sermons', 'name' => 'Sermons'), 'Members' => array('route' => 'members', 'name' => 'Members'));
         $view->with('pages', $pages);
     });
     \View::composer('includes.footer', function ($view) {
         //get the latest sermons
         $morning = \Crockenhill\Sermon::where('service', 'morning')->orderBy('date', 'desc')->first();
         $evening = \Crockenhill\Sermon::where('service', 'evening')->orderBy('date', 'desc')->first();
         // and create the view composer
         $view->with('morning', $morning);
         $view->with('evening', $evening);
     });
     \View::composer('layouts.members', function ($view) {
         $area = 'members';
         $links = \Crockenhill\Page::where('area', $area)->orderBy(\DB::raw('RAND()'))->take(5)->get();
         $view->with('links', $links);
     });
     \View::composer('page', function ($view) {
         if (\Request::segment(2)) {
             $slug = \Request::segment(2);
             $area = \Request::segment(1);
         } else {
             $slug = \Request::segment(1);
             $area = \Request::segment(1);
         }
         $headingpicture = '/images/headings/large/' . $slug . '.jpg';
         if ($area != 'whats-on') {
             $links = \Crockenhill\Page::where('area', $area)->where('slug', '!=', $slug)->where('slug', '!=', $area)->take(5)->get();
         } else {
             $links = \Crockenhill\Meeting::where('slug', '!=', $slug)->get();
         }
         $view->with('headingpicture', $headingpicture);
         $view->with('links', $links);
     });
 }
 public function getSeries($series)
 {
     $series_name = str_replace('-', ' ', \Illuminate\Support\Str::title($series));
     $area = 'sermons';
     $area_heading = \Illuminate\Support\Str::title($area);
     $breadcrumbs = '<li><a href="/' . $area . '">' . $area_heading . '</a></li><li><a href="/sermons/series">Series</a></li><li class="active">' . $series_name . '</li>';
     $sermons = \Crockenhill\Sermon::where('series', $series_name)->orderBy('date', 'desc')->paginate(8);
     return view('sermons.series', array('slug' => '', 'heading' => 'Sermons in the "' . $series_name . '" series', 'description' => '<meta name="description" content="Sermons by ' . $series_name . '">', 'breadcrumbs' => $breadcrumbs, 'content' => '', 'sermons' => $sermons));
 }