Ejemplo n.º 1
0
 public function createAction()
 {
     $model = new Evaluation();
     $input = Input::all();
     $validator = $model->validateInput($input);
     if ($validator->fails()) {
         app()->abort(422, $validator->errors()->first());
     }
     $audits = Input::get("auditResult");
     foreach ($audits as $audit) {
         DB::transaction(function () use($model, $audit) {
             $assertion = new Assertion(["date" => new Carbon(), "mode" => $audit["mode"], "test_id" => $audit["test"]["@id"], "test_type" => $audit["test"]["@type"], "result_type" => $audit["result"]["@type"], "result_outcome" => $audit["result"]["outcome"]]);
             /** @var Assertor $assertor */
             $assertor = Assertor::find(LDModel::getIdFromLdId(Input::get("creator.@id")));
             $model->fill(["date" => new Carbon()]);
             $model->creator()->associate($assertor);
             $model->save();
             /** @var Webpage $subject */
             $subject = Webpage::find(LDModel::getIdFromLdId($audit["subject"]));
             if (!$subject) {
                 app()->abort(422, "Subject not found");
             }
             $assertion->assertor()->associate($assertor);
             $assertion->subject()->associate($subject);
             $assertion->evaluation()->associate($model);
             $assertion->save();
         });
     }
     return $this->response($model);
 }
Ejemplo n.º 2
0
 public function values($society)
 {
     $data['circuit'] = Webpage::where('fieldname', '=', 'circuit_values')->first();
     $data['soc'] = $society;
     $data['society'] = Society::where('society', '=', $society)->first();
     return view('societies.values', $data);
 }
 /**
  * indexAction
  *
  * @param Request $request
  * @author Zaid Sadhoe <*****@*****.**>
  */
 public function indexAction(Request $request)
 {
     $ajax = new Request();
     $ajax->headers->set('X-Requested-With', 'XMLHttpRequest');
     $memberCount = Member::count();
     $webpageCount = Webpage::count();
     $resultCount = Result::count();
     return view('site.' . Site::getName() . '.page.index', ['request' => $request, 'memberCount' => $memberCount, 'webpageCount' => $webpageCount, 'resultCount' => $resultCount]);
 }
Ejemplo n.º 4
0
 /**
  * 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);
 }
Ejemplo n.º 5
0
 /**
  * Get Evaluation from session
  *
  * @param string $sessionKey
  * @param Member $user
  * @param Array $data
  * @return string sessionKey
  */
 private static function getEvaluation($sessionKey = null, Member $user = null, $data = null)
 {
     $session = session();
     $evaluation = null;
     if ($data && $sessionKey) {
         $webpage = Webpage::firstOrCreate(['url' => $data['HTTP_REFERER']]);
         if ($webpage->is_enabled) {
             $evaluation = $webpage->evaluations()->create(['member_id' => $user->id, 'ip' => $data['REMOTE_ADDR'], 'user_agent' => $data['HTTP_USER_AGENT']]);
             $session->put('tool.session.' . $sessionKey, $evaluation->id);
         }
     } else {
         if ($sessionKey) {
             $id = $session->get('tool.session.' . $sessionKey);
             $evaluation = Evaluation::find($id);
         }
     }
     return $evaluation;
 }
Ejemplo n.º 6
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(WebpagesRequest $request, $society, $id)
 {
     $webpage = Webpage::find($id);
     $webpage->fill($request->except('pageimage'));
     if ($request->file('pageimage')) {
         $fileName = "pageimage_" . $webpage->id . "." . $request->file('pageimage')->getClientOriginalExtension();
         $request->file('pageimage')->move(base_path() . '/storage/app/images/', $fileName);
         $webpage->pageimage = '/storage/app/images/' . $fileName;
         if ($webpage->dimensions != "") {
             $dim = explode(',', $webpage->dimensions);
             $img = Image::make(base_path() . $webpage->pageimage);
             $img->resize($dim[0], $dim[1]);
             $img->save(base_path() . '/storage/app/images/' . $fileName);
         }
     }
     $webpage->save();
     return redirect($society . '/webpages/')->with('okmessage', 'Data updated');
 }
Ejemplo n.º 7
0
 public function getAction($id)
 {
     return $this->response(Webpage::find($id));
 }