/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Conference::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['cnf_id' => $this->cnf_id, 'cnf_created' => $this->cnf_created]); $query->andFilterWhere(['like', 'cnf_title', $this->cnf_title])->andFilterWhere(['like', 'cnf_class', $this->cnf_class])->andFilterWhere(['like', 'cnf_controller', $this->cnf_controller])->andFilterWhere(['like', 'cnf_description', $this->cnf_description]); return $dataProvider; }
/** * Run the database seeds. * * @return void */ public function run() { // --------------------------------------------------------------------- // CONFERENCE 4 // --------------------------------------------------------------------- $conference = Conference::find(4); $item = ['name' => 'Laptop', 'quantity' => 1]; $item = new Item($item); $item->conference()->associate($conference); $item->save(); $item = ['name' => 'Projector', 'quantity' => 1]; $item = new Item($item); $item->conference()->associate($conference); $item->save(); }
/** * Delete a Manager of a Conference. * * @param Request $request * @param int $cid * @param int $uid * @return Response */ public function destroy(Request $request, $cid, $uid) { try { $conference = Conference::find($cid); if (!$conference) { return response()->error(404, 'Conference Not Found'); } $user = User::find($uid); if (!$user) { return response()->error(404, 'User Not Found'); } $conference->managers()->detach($user); return response()->success(); } catch (Exception $e) { return response()->error(); } }
/** * Run the database seeds. * * @return void */ public function run() { // --------------------------------------------------------------------- // CONFERENCE 1 // --------------------------------------------------------------------- $faker = Faker::create(); $user = Sentinel::findById(6); $conference = Conference::find(1); $countries = ['Canada', 'France', 'India', 'United States']; $genders = ['female', 'male']; for ($i = 0; $i < 100; ++$i) { $profile = ['first_name' => $faker->firstName, 'last_name' => $faker->lastName, 'city' => $faker->city, 'country' => $countries[rand(0, 3)], 'birthdate' => $faker->date($format = 'Y-m-d', $max = 'now'), 'gender' => $genders[rand(0, 1)]]; $profile = new Profile($profile); $profile->user()->associate($user); $profile->save(); $profile->conferences()->attach($conference->id, ['birthdate' => $profile->birthdate, 'country' => $profile->country, 'gender' => $profile->gender, 'status' => 'approved']); $conference->increment('attendee_count'); } // --------------------------------------------------------------------- // CONFERENCE 2 // --------------------------------------------------------------------- $conference = Conference::find(2); $event = $conference->events()->first(); $room = $conference->accommodations()->first()->rooms()->first(); $conferenceVehicle = $conference->vehicles()->first(); $eventVehicle = $event->vehicles()->first(); for ($i = 1; $i <= 7; ++$i) { $profile = Profile::find($i); $attendee = ['email' => $profile->email, 'phone' => $profile->phone, 'first_name' => $profile->first_name, 'middle_name' => $profile->middle_name, 'last_name' => $profile->last_name, 'city' => $profile->city, 'country' => $profile->country, 'birthdate' => $profile->birthdate, 'gender' => $profile->gender, 'accommodation_req' => true, 'accommodation_pref' => 1, 'arrv_ride_req' => true, 'arrv_date' => '2016-04-08', 'arrv_time' => '21:30', 'arrv_airport' => 'DEL', 'arrv_flight' => 'AC2273', 'dept_ride_req' => false, 'status' => 'approved']; $profile->conferences()->attach($conference, $attendee); $conference->increment('attendee_count'); $profile->events()->attach($event); $profile->rooms()->attach($room); $room->increment('guest_count'); $profile->conferenceVehicles()->attach($conferenceVehicle); $conferenceVehicle->increment('passenger_count'); $profile->eventVehicles()->attach($eventVehicle); $eventVehicle->increment('passenger_count'); } }
/** * Run the database seeds. * * @return void */ public function run() { // --------------------------------------------------------------------- // CONFERENCE 2 // --------------------------------------------------------------------- $conference = Conference::find(2); $accommodation = ['name' => 'Shangri-La Hotel Vancouver', 'address' => '1128 West Georgia Street', 'city' => 'Vancouver', 'country' => 'Canada']; $accommodation = new Accommodation($accommodation); $accommodation->conference()->associate($conference); $accommodation->save(); $room = ['room_no' => '100', 'guest_count' => 0, 'capacity' => 2]; $room = new Room($room); $room->accommodation()->associate($accommodation); $room->save(); $room = ['room_no' => '101', 'guest_count' => 0, 'capacity' => 3]; $room = new Room($room); $room->accommodation()->associate($accommodation); $room->save(); $room = ['room_no' => '102', 'guest_count' => 0, 'capacity' => 4]; $room = new Room($room); $room->accommodation()->associate($accommodation); $room->save(); $accommodation = ['name' => 'The Fairmont Hotel Vancouver', 'address' => '900 West Georgia Street', 'city' => 'Vancouver', 'country' => 'Canada']; $accommodation = new Accommodation($accommodation); $accommodation->conference()->associate($conference); $accommodation->save(); $room = ['room_no' => '200', 'guest_count' => 0, 'capacity' => 2]; $room = new Room($room); $room->accommodation()->associate($accommodation); $room->save(); $room = ['room_no' => '201', 'guest_count' => 0, 'capacity' => 3]; $room = new Room($room); $room->accommodation()->associate($accommodation); $room->save(); $room = ['room_no' => '202', 'guest_count' => 0, 'capacity' => 4]; $room = new Room($room); $room->accommodation()->associate($accommodation); $room->save(); }
/** * Run the database seeds. * * @return void */ public function run() { // --------------------------------------------------------------------- // CONFERENCE 2 // --------------------------------------------------------------------- $conference = Conference::find(2); $vehicle = ['name' => 'Airport Taxi', 'passenger_count' => 0, 'capacity' => 7, 'type' => 'arrival']; $vehicle = new ConferenceVehicle($vehicle); $vehicle->conference()->associate($conference); $vehicle->save(); $vehicle = ['name' => 'Airport Taxi', 'passenger_count' => 0, 'capacity' => 7, 'type' => 'departure']; $vehicle = new ConferenceVehicle($vehicle); $vehicle->conference()->associate($conference); $vehicle->save(); $event = $conference->events()->first(); $vehicle = ['name' => 'Hotel Shuttle', 'passenger_count' => 0, 'capacity' => 50, 'type' => 'arrival']; $vehicle = new EventVehicle($vehicle); $vehicle->event()->associate($event); $vehicle->save(); $vehicle = ['name' => 'Hotel Shuttle', 'passenger_count' => 0, 'capacity' => 50, 'type' => 'departure']; $vehicle = new EventVehicle($vehicle); $vehicle->event()->associate($event); $vehicle->save(); }
/** * Delete an Accommodation of a Conference. * * @param AccommodationRequest $request * @param int $cid * @param int $aid * @return Response */ public function destroy(AccommodationRequest $request, $cid, $aid) { try { $user = $this->isConferenceManager($request, $cid); if (!$user) { return response()->error(403, 'You are not a manager of this conference!'); } $conference = Conference::find($cid); if (!$conference) { return response()->error(404, 'Conference Not Found'); } $accommodation = Accommodation::find($aid); if (!$accommodation) { return response()->error(404, 'Accommodation Not Found'); } $accommodation->delete(); return response()->success(); } catch (Exception $e) { return response()->error(); } }
/** * Delete an Attendee of a Conference. * * @param ConferenceAttendeeRequest $request * @param int $cid * @param int $pid * @return Response */ public function destroy(ConferenceAttendeeRequest $request, $cid, $pid) { try { $conference = Conference::find($cid); if (!$conference) { return response()->error(404, 'Conference Not Found'); } $profile = Profile::find($pid); if (!$profile) { return response()->error(404, 'Profile Not Found'); } $eventVehicles = $conference->eventVehicles()->get(); foreach ($eventVehicles as $eventVehicle) { if ($eventVehicle->passengers()->where('profile_id', $pid)->exists()) { $eventVehicle->passengers()->detach($profile); $eventVehicle->decrement('passenger_count'); } } $events = $conference->events()->get(); foreach ($events as $event) { if ($event->attendees()->where('profile_id', $pid)->exists()) { $status = $event->attendees()->where('profile_id', $pid)->first()->pivot->status; $event->attendees()->detach($profile); if ($status == 'approved') { $event->decrement('attendee_count'); } } } $conferenceVehicles = $conference->vehicles()->get(); foreach ($conferenceVehicles as $conferenceVehicle) { if ($conferenceVehicle->passengers()->where('profile_id', $pid)->exists()) { $conferenceVehicle->passengers()->detach($profile); $conferenceVehicle->decrement('passenger_count'); } } $rooms = $conference->rooms()->get(); foreach ($rooms as $room) { if ($room->guests()->where('profile_id', $pid)->exists()) { $room->guests()->detach($profile); $room->decrement('guest_count'); } } $status = $conference->attendees()->where('profile_id', $pid)->first()->pivot->status; $conference->attendees()->detach($profile); if ($status == 'approved') { $conference->decrement('attendee_count'); } $uid = $request->header('ID'); $this->addActivity($uid, 'cancelled', $cid, 'conference attendance', $pid); return response()->success(); } catch (Exception $e) { return response()->error(); } }
/** * Delete an Event of a Conference. * * @param EventRequest $request * @param int $cid * @param int $eid * @return Response */ public function destroy(EventRequest $request, $cid, $eid) { try { $user = $this->isEventManager($request, $eid); if (!$user) { return response()->error(403, 'You are not a manager of this event!'); } $conference = Conference::find($cid); if (!$conference) { return response()->error(404, 'Conference Not Found'); } $event = Event::find($eid); if (!$event) { return response()->error(404, 'Event Not Found'); } $event->delete(); $this->addActivity($user->getKey(), 'deleted', $eid, 'event'); return response()->success(); } catch (Exception $e) { return response()->error(); } }
/** * Email a Conference Attendee about an update to their application. * * @param int $cid * @param int $pid * @param string $status * @return void * @throws Exception */ public function sendConferenceSignupEmail($cid, $pid, $status) { try { $conference = Conference::find($cid); $conferenceName = $conference->name; $profile = Profile::find($pid); $user = $profile->user()->first(); $email = $user->email; $name = $profile->first_name; if ($email && $user->receive_email && $profile->is_owner) { $subject = '[Huddle] Update to Your Conference Attendance Request for ' . $conferenceName; $body = 'Hi, ' . $name . '!' . "\n\n" . 'Your request to attend the conference ' . $conferenceName . ' has been ' . $status . '.'; Mail::queue([], [], function ($message) use($email, $subject, $body) { $message->to($email)->subject($subject)->setBody($body); }); } } catch (Exception $e) { throw $e; } }
/** * Retrieve all Events of a certain status from a Conference. * * @param Request $request * @param int $cid * @param string $status * @return Collection|Response */ public function eventsWithStatus(Request $request, $cid, $status) { try { $conference = Conference::find($cid); if (!$conference) { return response()->error(404, 'Conference Not Found'); } return $conference->events()->where('status', $status)->get(); } catch (Exception $e) { return response()->error(); } }
/** * Delete an Item of a Conference. * * @param ItemRequest $request * @param int $cid * @param int $iid * @return Response */ public function destroy(ItemRequest $request, $cid, $iid) { try { $user = $this->isConferenceManager($request, $cid); if (!$user) { return response()->error(403, 'You are not a manager of this conference!'); } $conference = Conference::find($cid); if (!$conference) { return response()->error(404, 'Conference Not Found'); } $item = Item::find($iid); if (!$item) { return response()->error(404, 'Item Not Found'); } $item->delete(); return response()->success(); } catch (Exception $e) { return response()->error(); } }
/** * Delete a Passenger of a Conference Vehicle. * * @param Request $request * @param int $cid * @param int $vid * @param int $pid * @return Response */ public function destroy(Request $request, $cid, $vid, $pid) { try { $conference = Conference::find($cid); if (!$conference) { return response()->error(404, 'Conference Not Found'); } $vehicle = ConferenceVehicle::find($vid); if (!$vehicle) { return response()->error(404, 'Vehicle Not Found'); } $profile = Profile::find($pid); if (!$profile) { return response()->error(404, 'Profile Not Found'); } $vehicle->passengers()->detach($profile); $vehicle->decrement('passenger_count'); return response()->success(); } catch (Exception $e) { return response()->error($e); } }
/** * Delete a Vehicle of a Conference. * * @param VehicleRequest $request * @param int $cid * @param int $vid * @return Response */ public function destroy(VehicleRequest $request, $cid, $vid) { try { $user = $this->isConferenceManager($request, $cid); if (!$user) { return response()->error(403, 'You are not a manager of this conference!'); } $conference = Conference::find($cid); if (!$conference) { return response()->error(404, 'Conference Not Found'); } $vehicle = ConferenceVehicle::find($vid); if (!$vehicle) { return response()->error(404, 'Vehicle Not Found'); } $vehicle->delete(); return response()->success(); } catch (Exception $e) { return response()->error(); } }