public function actionIndex() { $guest = null; $guestForm = new GuestLoginForm(); $cookies = Yii::$app->request->cookies; $guest_id = $cookies->getValue('guest_id'); if (isset($guest_id)) { $guest = Guest::find()->where(array('id' => $guest_id))->one(); if ($guestForm->load(Yii::$app->request->post())) { $guest->first_name = $guestForm->first_name; $guest->last_name = $guestForm->last_name; $guest->phone = $guestForm->phone; $guest->email = $guestForm->email; $guest->save(); } } if (!isset($guest)) { if ($guestForm->load(Yii::$app->request->post())) { $guest = $guestForm->login(); Yii::$app->response->cookies->add(new \yii\web\Cookie(['name' => 'guest_id', 'value' => $guest->id])); $this->redirect('/'); } } if (isset($guest)) { $guestForm->first_name = $guest->first_name; $guestForm->last_name = $guest->last_name; $guestForm->phone = $guest->phone; $guestForm->email = $guest->email; } return $this->render('index', array('guest' => $guest, 'guestForm' => $guestForm)); }
public function actionDisp() { if (Yii::$app->request->get('id')) { $done = Guest::find()->where(['id' => Yii::$app->request->get('id')])->one(); $done->done = true; $done->save(); } $data = Guest::find()->where(['done' => false])->all(); return $this->render('disp', ['data' => $data]); }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($society, $series, $id) { $data['sermon'] = Sermon::where('slug', '=', $id)->first(); 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['soc'] = $society; $data['society'] = Society::where('society', '=', $society)->first(); $data['pagetitle'] = $data['sermon']->sermon; return view('sermons.show', $data); }
/** * 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); }
public function removeGuest(Request $request, $eventId, $tableId) { $guest = Guest::find(Input::get('guest_id')); if ($guest->table_id !== $tableId) { return $this->prepareResponse('error', $guest->getName() . ' not seated at this table'); } $guest->table_id = null; $guest->save(); return $this->prepareResponse('success', $guest->getName() . ' removed from the table'); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { Guest::find($id)->Festival()->detach(); $guest = Guest::find($id); $a = Guest::where('id', $id)->delete(); $response = []; $response["name"] = $guest->name; if ($a > trashed()) { $statusCode = 200; $response['result'] = "deleted"; } else { $statusCode = 422; $response['result'] = "Cannot delete."; } return Response::json($response, $statusCode); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $guest = Guest::find($id); $guest->delete(); return Redirect::route('guests.index')->with('okmessage', 'Guest preacher has been deleted'); }