/** * Bind data to the view. * * @param View $view * @return void */ public function compose(View $view) { $society = $view->getData()['soc']; $data['services'] = Society::with('service')->where('society', '=', $society)->first(); foreach ($data['services']->service as $service) { if ($service['language'] == "English" and $service['description'] == "") { $service->description = "Our " . $service->servicetime . " service is led in English by a minister or local preacher and a team of musicians. Everyone is welcome!"; } elseif ($service['language'] == "isiZulu" and $service['description'] == "") { $service->description = "Our " . $service->servicetime . " service is led in isiZulu by a minister or local preacher and uses the liturgy and music of the Methodist Hymn Book. Everyone is welcome!"; } $data['allservices'][] = $service; } if (!count($data['services'])) { return View::make('errors.404'); } if (isset($view->getData()['pagetitle'])) { $data['pagetitle'] = $view->getData()['pagetitle']; } else { $data['pagetitle'] = $society; } $socid = Society::where('society', '=', $society)->select('id')->first()->id; if (Helpers::is_online() and $data['services']->society_calendar != "") { $privatecal = new GoogleCalendar(); $data['cals'] = $privatecal->getTen($data['services']->society_calendar, 8); } $data['sermon'] = Sermon::with(['series' => function ($query) use($socid) { $query->where('society_id', '=', $socid); }])->orderBy('servicedate', 'DESC')->first(); if (!$data['sermon'] or !$data['sermon']->series) { $data['sermon'] = "None"; } else { if ($data['sermon']->preachable_type == 'App\\Models\\Minister') { $data['preacher'] = Minister::find($data['sermon']->preachable_id); } elseif ($data['sermon']->preachable_type == 'App\\Models\\Guest') { $data['preacher'] = Guest::find($data['sermon']->preachable_id); } else { $data['preacher'] = Preacher::find($data['sermon']->preachable_id); } } $data['welcome_page'] = "together a transforming discipleship movement"; $data['welcome_page_pic'] = "/public/images/715.jpg"; if ($data['services']->roster) { $data['roster'] = $data['services']->roster; } $data['society'] = Society::where('society', '=', $society)->first(); if ($data['society']->roster) { $data['roster'] = $data['society']->roster; } $webpage = Webpage::where('society_id', '=', $data['society']->id)->get(); foreach ($webpage as $pg) { $data[$pg->fieldname] = $pg->fieldvalue; $data[$pg->fieldname . '_pic'] = $pg->pageimage; } $data['route'] = Route::getCurrentRoute()->getPath(); if ($data['route'] != "{society}" and $data['route'] != "/") { $linkadd = Helpers::makeUrl(strtolower($society), ''); } else { $linkadd = ""; } $menu['link'] = $linkadd . "#sundays"; $menu['label'] = "Sundays"; $menu['longlabel'] = "Sunday services"; $data['menu'][] = $menu; $data['youth'] = Mission::where('society_id', '=', $data['society']->id)->where('category', '=', 'youth')->orderBy('created_at')->take(5)->get(); if (count($data['youth'])) { $menu['link'] = $linkadd . "#youth"; $menu['label'] = "Youth"; $menu['longlabel'] = "Children and Youth"; $data['menu'][] = $menu; } $data['groups'] = Group::where('society_id', '=', $data['society']->id)->where('publish', '=', 1)->get(); if (count($data['groups'])) { foreach ($data['groups'] as $obj) { $dum[0] = $obj->groupname; $dum[1] = $obj->latitude; $dum[2] = $obj->longitude; $dum[3] = Helpers::makeUrl(strtolower($data['services']->society), 'groups/' . $obj->slug); $fin[] = $dum; } $data['fin'] = json_encode($fin); $menu['link'] = "#groups"; $menu['label'] = "Groups"; $menu['longlabel'] = "Small groups"; $data['menu'][] = $menu; } else { $data['fin'] = ""; } $data['missions'] = Mission::where('society_id', '=', $data['society']->id)->where('category', '=', 'project')->take(5)->get(); if (count($data['missions'])) { $menu['link'] = $linkadd . "#projects"; $menu['label'] = "Projects"; $menu['longlabel'] = "Mission projects"; $data['menu'][] = $menu; } $blogs = Blog::with('individual')->orderBy('created_at', 'desc')->take(10)->get(); if (count($blogs)) { $first = true; foreach ($blogs as $blog) { $societies = explode(',', $blog->societies); if (in_array($data['society']->id, $societies)) { if ($first) { $data['firstblog'] = $blog; $first = false; } else { $data['blogs'][] = $blog; } } } if (isset($data['firstblog'])) { $menu['link'] = $linkadd . "#blog"; $menu['label'] = "Blog"; $menu['longlabel'] = "Latest blogs"; $data['menu'][] = $menu; } } $menu['link'] = $linkadd . "#contact"; $menu['label'] = "Contact"; $menu['longlabel'] = "Contact us"; $data['menu'][] = $menu; $data['counter'] = 1; $view->with('data', $data); }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($society, $slug) { $data['soc'] = $society; $data['individual'] = Individual::where('slug', '=', $slug)->first(); if ($data['individual'] and $data['individual']->social) { $socials = explode(',', $data['individual']->social); foreach ($socials as $social) { if (strpos($social, 'twitter')) { $data['socials']['twitter'] = $social; } elseif (strpos($social, 'facebook')) { $data['socials']['facebook'] = $social; } elseif (strpos($social, 'instagram')) { $data['socials']['instagram'] = $social; } elseif (strpos($social, 'youtube')) { $data['socials']['youtube'] = $social; } } } if ($data['individual']) { $id = $data['individual']->id; if (count(Preacher::where('individual_id', '=', $id)->get()) > 0) { $data['preacher'] = Preacher::with(array('sermons' => function ($query) { $query->orderBy('created_at', 'DESC'); }))->where('individual_id', '=', $id)->first(); } elseif (count(Minister::with('sermons')->where('individual_id', '=', $id)->get()) > 0) { $data['preacher'] = Minister::where('individual_id', '=', $id)->first(); } $data['pagetitle'] = $data['individual']->firstname . " " . $data['individual']->surname; } else { $data['preacher'] = Guest::where('slug', '=', $slug)->first(); $data['pagetitle'] = $data['preacher']->firstname . " " . $data['preacher']->surname; $id = 0; } if (isset($data['preacher'])) { $sermons = $data['preacher']->sermons->lists('id')->all(); $data['sermons'] = Sermon::wherein('id', $sermons)->orderBy('servicedate', 'DESC')->paginate(5); } $data['blogs'] = Blog::where('individual_id', '=', $id)->orderBy('created_at', 'DESC')->limit(9)->get(); return View::make('individuals.show', $data); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($society, $series, $id) { $sermon = Sermon::find($id); $sermon->delete(); return redirect(url('/') . '/' . $society . '/series')->with('okmessage', 'Sermon has been deleted'); }
public function feed($society) { $feed = App::make("feed"); // cache the feed for 60 minutes (second parameter is optional) $feed->setCache(0, 'LowerTugelaCircuitFeed'); // check if there is cached feed and build new only if is not if (!$feed->isCached()) { $society = Society::where('society', '=', $society)->first(); // creating rss feed with our most recent 20 posts $blogs = Blog::where('created_at', '>', '2016-02-13')->orderBy('created_at', 'desc')->take(20)->get(); $sermons = Sermon::where('servicedate', '>', '2016-02-13')->orderBy('servicedate', 'desc')->orderBy('created_at', 'desc')->take(20)->get(); // set your feed's title, description, link, pubdate and language $feed->title = $society->society . ' Methodist Church'; $feed->description = 'Together, a transforming discipleship movement'; $feed->logo = 'http://church.net.za/public/images/logo.jpg'; $feed->link = url('feed'); $feed->setDateFormat('datetime'); // 'datetime', 'timestamp' or 'carbon' $feed->pubdate = date('d-m-Y'); $feed->lang = 'en'; $feed->setShortening(true); // true or false $feed->setTextLimit(120); // maximum length of description text $feeddata = array(); foreach ($blogs as $blog) { // set item's title, author, url, pubdate, description and content if ($blog->blogimage != "") { $imgurl = url($blog->blogimage); } elseif ($blog->individual->photo) { $imgurl = url($blog->individual->photo); } elseif ($society->logo) { $imgurl = url($society->logo); } else { $imgurl = "http://church.net.za/public/images/logo.jpg"; } $fulldescrip = strip_tags($blog->post); $dum['title'] = $blog->title; $dum['author'] = $imgurl; $dum['link'] = url('/blog#' . $blog->id); $dum['pubdate'] = $blog->created_at; $dum['summary'] = "A new blog post has been published on our site."; $dum['content'] = $fulldescrip; $feeddata[] = $dum; } foreach ($sermons as $sermon) { // set item's title, author, url, pubdate, description and content $seriesimage = url($sermon->series->seriesimage); if ($sermon->preachable_type == "App\\Models\\Guest") { $preacher = $sermon->preachable->firstname . " " . $sermon->preachable->surname; } else { $preacher = $sermon->preachable->individual->firstname . " " . ($preacher = $sermon->preachable->individual->surname); } $fulldescrip = "Recording of a sermon preached by " . $preacher . " at " . $society->society . ' Methodist Church on ' . date("l j F Y", strtotime($sermon->servicedate)) . '. Bible readings: ' . $sermon->readings; $dum['title'] = $sermon->sermon; $dum['author'] = $seriesimage; $dum['link'] = url('/sermons/' . $sermon->series->slug . '/' . $sermon->slug); $dum['pubdate'] = $sermon->servicedate . " 12:00:00"; $dum['summary'] = "A new sermon has been uploaded to our site."; $dum['content'] = $fulldescrip; $feeddata[] = $dum; } usort($feeddata, function ($a, $b) { return strcmp($b["pubdate"], $a["pubdate"]); }); } foreach ($feeddata as $fd) { $feed->add($fd['title'], $fd['author'], $fd['link'], $fd['pubdate'], $fd['summary'], $fd['content']); } return $feed->render('atom'); }