/**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $slug = 'whats-on';
     $area = $slug;
     $page = \Crockenhill\Page::where('slug', $slug)->first();
     $heading = $page->heading;
     $breadcrumbs = '<li class="active">' . $page->heading . '</li>';
     $description = '<meta name="description" content="' . $page->description . '">';
     $content = $page->body;
     return view('page', array('slug' => $slug, 'heading' => $heading, 'description' => $description, 'area' => $area, 'breadcrumbs' => $breadcrumbs, 'content' => $content));
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     if (\Gate::denies('see-member-content')) {
         abort(403);
     }
     // Set information about page to enable lookup
     $slug = 'documents';
     $area = 'members';
     // Look up page
     $page = \Crockenhill\Page::where('slug', $slug)->first();
     // Set details
     $heading = 'Documents';
     $breadcrumbs = '<li class="active">' . $page->heading . '</li>';
     $content = $page->body;
     // Get documents
     $documents = \Crockenhill\Document::get();
     return view('documents.index', array('slug' => $slug, 'heading' => $heading, 'description' => '<meta name="description" content="{{$heading}}">', 'area' => $area, 'breadcrumbs' => $breadcrumbs, 'content' => $content, 'documents' => $documents));
 }
 /**
  * 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 create()
 {
     if (\Gate::denies('edit-songs')) {
         abort(403);
     }
     // Define slug and area to enable lookup of page in database
     $slug = 'scripture-reference';
     $area = 'members';
     // Find relevant links
     $links = \Crockenhill\Page::where('area', $area)->where('slug', '!=', $slug)->where('slug', '!=', $area)->where('slug', '!=', 'homepage')->orderBy(\DB::raw('RAND()'))->take(5)->get();
     // Set values
     $heading = 'Add a new song to the list';
     $breadcrumbs = '<li>' . link_to('members', 'Members') . '&nbsp</li>
                   <li><a href="/members/songs">Songs</a></li>
                   <li class="active">' . $heading . '</li>';
     // Load content
     $content = '';
     // Present page
     return view('songs.create', array('slug' => $slug, 'heading' => $heading, 'description' => '<meta name="description" content="' . $heading . '">', 'area' => $area, 'breadcrumbs' => $breadcrumbs, 'content' => $content, 'links' => $links));
 }
 public function destroy($slug)
 {
     if (\Gate::denies('edit-pages')) {
         abort(403);
     }
     $page = \Crockenhill\Page::where('slug', $slug)->first();
     $page->delete();
     return redirect('/members/pages')->with('message', 'Page successfully deleted!');
 }
 public function getSerieses()
 {
     $slug = 'series';
     $page = \Crockenhill\Page::where('slug', $slug)->first();
     $area = $page->area;
     $area_heading = \Illuminate\Support\Str::title($page->area);
     $breadcrumbs = '<li><a href="/' . $page->area . '">' . $area_heading . '</a></li><li class="active">' . $page->heading . '</li>';
     $series = \Crockenhill\Sermon::select('series')->distinct()->orderBy('date')->get();
     return view('sermons.serieses', array('slug' => $slug, 'heading' => $page->heading, 'description' => '<meta name="description" content="' . $page->description . '">', 'breadcrumbs' => $breadcrumbs, 'content' => $page->body, 'series' => $series));
 }