Esempio n. 1
0
 /**
  * La fonction addGuest(Request $request) permet d'ajouter un invité à un événement si ce dernier existe, qu'il n'est pas complet et si les données sont valides.
  * @param Request $request - La requête contenant les paramètres.
  * @return Redirect - Une redirection avec les messages selon le bon déroulement de la fonction.
  */
 public function addGuest(Request $request)
 {
     $data = $request->all();
     $validator = Validator::make($request->all(), ['eventId' => "required|integer", 'first_name' => 'required|string', 'last_name' => 'required|string', 'email' => 'required|email', 'gender' => 'required|string|in:male,female']);
     if ($validator->passes()) {
         if (Event::existTechId($data['eventId'])) {
             $event = Event::find($data['eventId']);
             if (Event::isNotSoldOut($event->id)) {
                 if (!Guest::exist($data['email'])) {
                     $guest = new Guest();
                     $guest->first_name = $data['first_name'];
                     $guest->last_name = $data['last_name'];
                     $guest->email = $data['email'];
                     $guest->gender = $data['gender'];
                     $guest->save();
                 } else {
                     $guest = Guest::where('email', $data['email'])->first();
                     if (Guest::participateToEvent($data['eventId'], $guest->id)) {
                         return redirect('/events')->with('error', $guest->first_name . ' ' . $guest->last_name . ' participe déjà à l\'événement ' . $event->name);
                     }
                 }
                 $event->guests()->attach($guest->id);
                 return redirect('/events')->with('status', $guest->first_name . ' ' . $guest->last_name . ' a été ajouté à l\'événement ' . $event->name);
             }
             return redirect('/events')->with('error', 'Cet événement est complet');
         }
         return redirect('/events')->with('error', 'Cet événement n\'existe pas');
     }
     return redirect('/events')->withErrors($validator)->withInput();
 }
 public function join($eventId)
 {
     $user = \JWTAuth::parseToken()->toUser();
     $event = \App\Event::find($eventId);
     $event->users()->attach($user->id);
     response()->json(['message' => 'User Joined Event'], 200);
 }
 /**
  * Our index page listing all stations
  *
  * @author David Varney
  */
 public function index(Request $request)
 {
     $default_event = Event::first();
     $event_id = $request->input('event_id', $default_event->id);
     $event = Event::find($event_id);
     $stations = $event->stations()->get();
     return view('admin.station_data.index', array('title' => 'Admin: Station Data', 'stations' => $stations, 'event_id' => $event_id, 'events' => Event::lists('name', 'id')));
 }
Esempio n. 4
0
 public function showEventDiary($eventId, $page = 1)
 {
     $pageSize = 10;
     $accountArray = Cache::get('accountList');
     if (!Cache::has('tradeList-' . $eventId . '-' . $page)) {
         Cache::put('tradeList-' . $eventId . '-' . $page, Trade::where('event_id', '=', $eventId)->orderBy('trade_at', 'asc')->skip(($page - 1) * $pageSize)->take($pageSize)->get(), 10);
     }
     return view('event.diary')->with(['eventList' => Cache::get('events'), 'eventInfo' => Event::find($eventId), 'tradeList' => Cache::get('tradeList-' . $eventId . '-' . $page), 'accountList' => json_encode($accountArray), 'fileLinkList' => DiaryAttachedFiles::where('event_id', '=', $eventId)->get(), 'totalPageNumber' => ceil(Trade::where('event_id', '=', $eventId)->count() / $pageSize), 'currentPageNumber' => $page]);
 }
Esempio n. 5
0
 /**
  * View to allow users to upload photos to an event
  * @param  Request $request
  * @param  string  $encryptedEventID
  * @return array The data necessary to pass to the view
  */
 public static function uploadFiles($encryptedEventID)
 {
     $data['eventID'] = Crypt::decrypt($encryptedEventID);
     $data['event'] = Event::find($data['eventID']);
     if (Auth::check()) {
         $data['images'] = Auth::user()->media->where('event_id', $data['eventID'])->sortBy('id');
     }
     return $data;
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     //
     $event = Event::find($id);
     if (!$event) {
         return response()->json(['error' => 'Event does not exist', 'code' => 'e101'], 404);
     }
     return response()->json(['data' => $this->transform($event->toArray())], 200);
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     for ($i = 1; $i <= 3; $i++) {
         $partner = Partner::find($i);
         $event = Event::find(1);
         $distance = LocationController::getMapsMatrixDistance($event->location, $partner->location);
         $event->partners()->save($partner, ['distance' => $distance]);
     }
 }
Esempio n. 8
0
 public static function buildPartnerResultByEvent($id)
 {
     $event = Event::find($id);
     $partners = $event->partners;
     foreach ($partners as $partner) {
         $partner->type = $partner->type->name;
     }
     return $partners;
 }
Esempio n. 9
0
 /**
  * @param $crsid
  * @return mixed
  */
 public function getEventAttendee($event_id, $crsid)
 {
     $event = Event::find($event_id);
     if ($event === null) {
         return null;
     }
     $attendee = $event->attendees()->where('crsid', strtolower($crsid))->first();
     return $attendee;
 }
 public function testMarkingActivitiesToUsers()
 {
     $this->logIn();
     session()->set('admin', 1);
     self::initData();
     $event = Event::find(1);
     $group = $event->group;
     $eventOccurrence = $event->eventOccurrences->first();
     $this->visit('/events/' . $event->id . '/occurrences/' . $eventOccurrence->id)->check($group->users->first()->id)->press('Merkitse suoritetuiksi')->seePageIs('/events/' . $event->id . '/occurrences/' . $eventOccurrence->id)->seeInDatabase('activity_user', ['activity_id' => $eventOccurrence->activities->first()->id, 'user_id' => $group->users->first()->id]);
 }
Esempio n. 11
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     if (!($event = Event::find($id))) {
         return \Redirect::to('/home')->withError('Evento não encontrado');
     }
     if ($event->delete()) {
         return \Redirect::to('/home')->withMessage(['type' => 'success', 'body' => 'Evento excluído com sucesso']);
     }
     return \Redirect::back()->withMessage(['type' => 'error', 'body' => 'Não foi possivel excluir as informações do seu evento'])->withInput();
 }
 public function deleteEvent()
 {
     $result = ['success' => false];
     $id = Input::get('id');
     if (isset($id) && !empty($id) && Event::find($id)) {
         $event = Event::find($id);
         $event->delete();
         $result['success'] = true;
     }
     return json_encode($result);
 }
Esempio n. 13
0
function eventMissingCrucialInformation($id)
{
    $event = \App\Event::find($id);
    if (\App\Category::find($event->type)) {
        return false;
    }
    if (strlen($event->description) < 1) {
        return false;
    }
    return true;
}
 public function showevent($id, $event)
 {
     $user = Auth::user();
     $reg = NULL;
     if ($user) {
         $reg = Register::where('userid', $user->id)->where('eventid', $event)->first();
     }
     $fest = Fest::find($id);
     $event = Event::find($event);
     return view('user.event', ['user' => Auth::user(), 'event' => $event, 'fest' => $fest, 'reg' => $reg]);
 }
 /**
  * Return json for DataTables.
  *
  * @return \Illuminate\Http\Response
  */
 public function data($event_id)
 {
     // grab event
     $event = Event::find($event_id);
     // grab rows
     $advisors = Advisor::leftJoin('schools', 'advisors.school_id', '=', 'schools.id')->leftJoin('attendees', 'advisors.id', '=', 'attendees.advisor_id')->leftJoin('invoices', 'invoices.advisor_id', '=', 'advisors.id')->select(['advisors.id', 'advisors.created_at', 'advisors.name', 'advisors.email', 'advisors.attending_advisor', 'advisors.comments', 'schools.name as school', 'schools.region as region', DB::raw('count(attendees.id) as attendees'), 'invoices.key as invoice'])->where('advisors.event_id', $event_id)->groupBy('advisors.id')->get();
     return Datatables::of($advisors)->editColumn('created_at', '{{ $created_at->toDateTimeString() }}')->editColumn('attendees', '<a href="{{ url(\'/admin/event/' . $event_id . '/advisor/\'.$id.\'/attendees\') }}">{{ $attendees }}</a>')->editColumn('invoice', '<a href="{{ url(\'/event/' . $event->slug . '/invoice/\'.$invoice) }}"><i class="icon-file"></i></a>')->addColumn('actions', '
             <a href="{{ url(\'admin/event/' . $event_id . '/advisor/\'.$id.\'/edit\') }}" class="btn btn-primary btn-xs"><i class="icon-pencil"></i></a>
             <a href="{{ url(\'admin/event/' . $event_id . '/advisor/\'.$id.\'/remove\') }}" class="btn btn-danger btn-xs"><i class="icon-remove"></i></a>
         ')->make(true);
 }
Esempio n. 16
0
 public function update($eventid, $newArray)
 {
     if ($newArray != NULL) {
         $event = Event::find($id);
         if ($event->question != NULL) {
             Pivot::where('eventid', $eventid)->delete();
             $event->question()->sync($newArray);
         }
     }
     return redirect('event/detail/' . $eventid);
 }
Esempio n. 17
0
 public function testEventUpdate()
 {
     $this->startUp();
     $event = Event::create(array('name' => 'The Red Wedding', 'uid' => $this->user->uid, 'location' => 'Winnipeg'));
     $event->location = 'Castle Frey';
     $eid = $event->eid;
     $event->save();
     $event = Event::find($eid);
     $result = $event->location == 'Castle Frey';
     $this->assertTrue($result);
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function postEdit(Request $request, $id)
 {
     //
     //        $date = Carbon::parse($request->input('event_date'))->toDateTimeString();
     $event = Event::find($id);
     $event->event_name = $request->input('event_name');
     $event->event_date = $request->input('event_date');
     $event->event_place = $request->input('event_place');
     $event->event_description = $request->input('event_description');
     $event->save();
     return redirect('/admin/event');
 }
Esempio n. 19
0
 /**
  * Gets the featured event
  *
  * @return mixed
  */
 protected function getFeaturedEvent()
 {
     // Get event ID or latest event if doesn't exist
     $event_id = Cache::get(EventsController::FEATURED_EVENT_ID_KEY, DB::table('events')->max('id'));
     $event = Event::find($event_id);
     // Get max. 160 characters from description as summary if not already set
     $summary = Cache::get(EventsController::FEATURED_EVENT_SUMMARY_KEY, substr(strip_tags($event->description), 0, 160) . '...');
     $result = new \stdClass();
     $result->event = $event;
     $result->summary = $summary;
     return $result;
 }
 public function getRegisteredEventsAttribute()
 {
     $schedule_query = ' select e.id, e.activity, v.fullname as venue, e.datetime ';
     $schedule_query .= ' from t_scores s ';
     $schedule_query .= ' left join t_events e on e.id = s.event_id ';
     $schedule_query .= ' left join t_venues v on v.id = e.venue_id ';
     $schedule_query .= ' where s.player_id = ? and e.datetime >= ? ';
     $schedule_query .= ' order by week_num, venue_id, datetime asc ';
     $events = DB::select($schedule_query, [$this->id, date('Y-m-d')]);
     return array_map(function ($event) {
         return Event::find($event->id);
     }, $events);
 }
Esempio n. 21
0
 public function destroy(DiscountFormRequest $request, $id)
 {
     $event = Event::find($request->input('event'));
     $discount = Discount::find($id);
     if ($discount && $event->user_id == $request->user()->id) {
         $discount->delete();
         \Flash::success('Discount deleted');
     } else {
         \Flash::danger('Sorry, permission denied');
     }
     //return redirect(action('EventsController@admin', $request->input('event')));
     return Redirect::back()->with(['tabName' => 'discounts']);
 }
Esempio n. 22
0
 public function update(array $data, $id)
 {
     $event_time = $this->dateToTime($data['event_time']);
     $start_at = $event_time['start_time'];
     $end_at = $event_time['end_time'];
     $event = Event::find($id);
     $event->title = $data['title'];
     $event->planner = $data['planner'];
     $event->start_at = $start_at;
     $event->end_at = $end_at;
     //$event->type = $data['type'];
     $event->save();
     return $event;
 }
Esempio n. 23
0
 public function update($event_id)
 {
     $event = Event::find($event_id);
     if (empty($event)) {
         return data([false]);
     }
     $method = '';
     if (isset($this->request->participant_id)) {
         $method = 'toggleParticipant';
     } else {
         $method = 'updateEvent';
     }
     return $this->{$method}($event);
 }
Esempio n. 24
0
 public function shortDetails($id)
 {
     $event = Event::find($id);
     $hostId = $event->user_id;
     $gameId = $event->boardgame_id;
     $boardGame = Boardgame::find($gameId);
     $user = User::find($hostId);
     $flagApproveEnable = \DB::table('event_user')->where('event_id', '=', $event->id)->where('user_id', '=', \Auth::id())->count() == 0;
     $event->event_date_formated = Date('g:ia \\o\\n jS F Y', strtotime($event->event_date));
     $peopleCount = \DB::table('event_user')->where('event_id', $id)->where('status', 'approved')->count();
     $event->people_count = $peopleCount;
     $flagApproveEnable = true;
     $var = ['event' => $event, 'user' => $user, 'boardGame' => $boardGame, 'flagApproveEnable' => $flagApproveEnable];
     return view('events.short-details', $var);
 }
 /**
  * Display the specified event.
  *
  * @param  int  $calendar_id
  * @param  int  $ event_id
  * @return Response
  */
 public function show($calendar_id, $event_id)
 {
     try {
         if (Input::get('format') == 'ical') {
             $event = Event::find($event_id);
             $ical_event = event_to_ical($event);
             return $ical_event;
         } else {
             $event = $this->user->calendars->find($calendar_id)->events->find($event_id);
             return $event;
         }
     } catch (ModelNotFoundException $e) {
         return response('Not Found!', 404);
     }
 }
 public static function getPollOptionsFromEid($eid)
 {
     $event = Event::find($eid);
     //Retrieving Polls for Display
     $polls = Poll::getEventPolls($eid);
     $all_poll_options = [];
     foreach ($polls as $poll) {
         $options = [];
         if (null != $poll) {
             $options = PollOption::getPollOptions($poll->pid);
         }
         array_push($all_poll_options, $options);
     }
     return $all_poll_options;
 }
Esempio n. 27
0
 /**
  * Delete an extra
  * @param Request $request
  * @param $id
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function destroy(Request $request, $id)
 {
     $event = Event::find($request->input('event'));
     $extra = Extra::find($id);
     if ($extra && $event->user_id == $request->user()->id) {
         $extra->delete();
         //Flash a message to the user
         \Flash::success('Extra deleted');
     } else {
         //Flash a message to the user
         \Flash::danger('Sorry, permission denied');
     }
     //Redirect back to the admin page
     //return redirect(action('EventsController@admin', $request->input('event')));
     return Redirect::back()->with(['tabName' => 'extras']);
 }
Esempio n. 28
0
 /**
  * Delete a detail
  * @param Request $request
  * @param $id
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function destroy(Request $request, $id)
 {
     $event = Event::find($request->input('event'));
     $detail = Detail::find($id);
     if ($detail && $event->user_id == $request->user()->id) {
         $detail->delete();
         //Flash a message to the user
         \Flash::success('Detail deleted');
     } else {
         //Flash a message to the user
         \Flash::danger('Sorry, permission denied');
     }
     $event = Event::findOrFail($request->input('event'));
     //Redirect back to the admin page
     return redirect(action('EventsController@admin', $event->slug));
 }
Esempio n. 29
0
 public function rules()
 {
     $event = Event::find($this->event_code);
     switch ($this->method()) {
         case 'GET':
         case 'DELETE':
             return [];
         case 'POST':
             return ['code' => 'required|unique:events,code', 'event_name' => 'required', 'event_place' => 'required', 'event_date' => 'required', 'cert_type' => 'required', 'theme' => 'required'];
         case 'PUT':
         case 'PATCH':
             return ['event_name' => 'required', 'event_place' => 'required', 'event_date' => 'required', 'cert_type' => 'required', 'theme' => 'required'];
         default:
             break;
     }
 }
Esempio n. 30
0
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     view()->composer('*', function ($view) {
         if (auth()->check()) {
             $newCount = auth()->user()->notifications()->where('seen', '0')->orderBy('created_at', 'desc')->get();
             $newCount = count($newCount);
             $notifications = \Auth::user()->notifications()->orderBy('created_at', 'desc')->get();
             foreach ($notifications as $notification) {
                 if ($notification->seen == 0) {
                     $notification->class = 'notification-unseen';
                 }
                 $notification->event = Event::find($notification->object_id);
             }
             $view->with('notifications', $notifications)->with('newCount', $newCount);
         }
     });
 }