/**
  * Get users events
  *
  * @depends testAuthUser
  * @param  array      $auth
  * @return void
  */
 public function testGetUsersEvents($auth)
 {
     // Instanciate apihelper
     $api = new \App\Helpers\ApiHelper();
     $events = $api->index('events?filter[and][][user_id]=' . $auth->id . '&sort[desc][]=id');
     return $events;
 }
 /**
  * Test Create Event
  *
  * @return event
  */
 public function testCreateEvent()
 {
     $eventData = ['user_id' => '1', 'title' => 'Unit test event ' . time(), 'address1' => '123 st', 'zipcode' => '89017', 'tags' => 'concerts', 'is_published' => 1, 'meta' => '{"schedules": [{"timeZoneId": 6, "daysOfWeek": null, "start": {"date": "2020-10-31", "time": "12:00:00"}, "end": {"date": "2020-10-31", "time": "17:00:00"}, "repeat": null}]}'];
     $api = new \App\Helpers\ApiHelper();
     $event = $api->store('events', $eventData);
     $event = $event['data']['event'];
     return $event;
 }
 /**
  * @depends testUser
  * @return $events
  */
 public function testGetEvents($auth)
 {
     // Instanciate apihelper
     $api = new \App\Helpers\ApiHelper();
     // Grab a user from
     $events = $api->index('events?filter[and][][is_published]=1&filter[and][][user_id]=' . $auth->id);
     $events = $events['data']['events'];
     return $events;
 }
 /**
  * This will grab a single event to edit schedules
  *
  * @depends testGetEvents
  */
 public function testGrabSchedule($events)
 {
     $event = $events[0];
     // Instanciate apihelper
     $api = new \App\Helpers\ApiHelper();
     $event = $api->show('events', $event['id'] . '?with[]=schedules');
     $schedule = $event['data']['event']['schedules'][0];
     return $schedule;
 }
 public function testGetEvent()
 {
     // Instanciate ApiHelper
     $api = new \App\Helpers\ApiHelper();
     // Grab an event from the DB using api
     $event = $result = $api->index('events?with[]=user');
     // Define the event
     $event = $event['data']['events'][0];
     return $event;
 }
 /**
  * testPostAccountLogin (Logged out)
  *
  * @return $user
  */
 public function testAccountLogin()
 {
     // Instanciate apihelper
     $api = new \App\Helpers\ApiHelper();
     // Grab a user from
     $user = $api->show('users', '4');
     // Set usersname
     $user = $user['data']['user'];
     $result = $this->visit('account/login')->type($user['email'], 'email')->type('timberlake', 'password')->press('Sign in')->see($user['email'])->see('Search Events Near You')->seePageIs('/');
     return $user;
 }
 /**
  * testPostAccountLogin (Logged out)
  *
  *
  */
 public function testAuthUser()
 {
     // Instanciate apihelper
     $api = new \App\Helpers\ApiHelper();
     // Grab a user from
     $user = $api->show('users', '3?with[]=events');
     // Set usersname
     $user = $user['data']['user'];
     $auth = new ApiGenericUser(['id' => $user['id']]);
     return $auth;
 }
Ejemplo n.º 8
0
 protected static function getApiUserInfo(Request $request)
 {
     $api_key = $request->input('key');
     if (!$api_key) {
         // no API key provided -- check whether anonymous API is on
         if (env('SETTING_ANON_API') == 'on') {
             $username = '******' . $request->ip();
         } else {
             abort(401, "Authentication token required.");
         }
         $user = (object) ['username' => $username];
     } else {
         $user = User::where('active', 1)->where('api_key', $api_key)->where('api_active', 1)->first();
         if (!$user) {
             abort(401, "Invalid authentication token.");
         }
         $username = $user->username;
     }
     $api_limit_reached = ApiHelper::checkUserApiQuota($username);
     if ($api_limit_reached) {
         abort(403, "Quota exceeded.");
     }
     return $user;
 }
 /**
  * Show List of events
  * @return friends page view
  */
 public function showAllEvents()
 {
     // Illuminate the APIHelper
     $api = new \App\Helpers\ApiHelper();
     $limit = 200;
     $url = 'events?filter[and][][times.end]=date&limit=' . $limit . '&fields[]=slug&fields[]=title&fields[]=latitude&fields[]=longitude&fields[]=address1&fields[]=address2&fields[]=city&fields[]=state&fields[]=zipcode&fields[]=phone&fields[]=venueName&fields[]=tags&fields[]=nextEvent&with[]=tags&with[]=nextEvent';
     if (\Auth::check()) {
         $url .= '&auth_user_id=' . \Auth::user()->id;
     }
     $events = $api->index($url);
     $events = $events['data']['events'];
     for ($i = 0; $i < count($events); $i++) {
         $events[$i] = ['title' => isset($events[$i]['title']) ? $events[$i]['title'] : null, 'slug' => isset($events[$i]['slug']) ? $events[$i]['slug'] : null, 'venueName' => isset($events[$i]['venueName']) ? $events[$i]['venueName'] : null, 'address1' => isset($events[$i]['address1']) ? $events[$i]['address1'] : null, 'address2' => isset($events[$i]['address2']) ? $events[$i]['address2'] : null, 'city' => isset($events[$i]['city']) ? $events[$i]['city'] : null, 'state' => isset($events[$i]['state']) ? $events[$i]['state'] : null, 'zipcode' => isset($events[$i]['zipcode']) ? $events[$i]['zipcode'] : null, 'phone' => isset($events[$i]['phone']) ? $events[$i]['phone'] : null, 'latitude' => isset($events[$i]['latitude']) ? $events[$i]['latitude'] : null, 'longitude' => isset($events[$i]['longitude']) ? $events[$i]['longitude'] : null, 'tags' => isset($events[$i]['tags']) ? $events[$i]['tags'] : null, 'nextEvent' => isset($events[$i]['nextEvent']) ? date('m/d/Y g:ia', strtotime($events[$i]['nextEvent']['start'])) : ''];
     }
     return $events;
 }
 /**
  *
  * Sets logged in users friends if any for show method
  *
  */
 protected function setFriends($api)
 {
     $friends = $api->index('users/' . \Auth::user()->id . '?with[]=friends&with[]=ticketInventories&with[]=stripeManagedAccounts&auth_user_id=' . \Auth::user()->id);
     $friends = isset($friends['data']['user']['friends']) ? $friends['data']['user']['friends'] : [];
     // Strip fields needed for friends list
     $friends = ApiHelper::stripFieldsCollection($friends, ['id', 'email', 'username', 'firstName', 'lastName', 'avatar', 'pivot']);
     return $friends;
 }
 /**
  * Display the reservation confirmation page.
  *
  * @param  $slug returns title of specified event
  * @param  $reserve holds name of reservation
  * @param  $confirmation holds confirmation message
  *
  * @return Returns reservation confirmation for all reservations made and returns view
  */
 public function showReservationConfirmation($slug)
 {
     // Instantiate the APIHelper
     $api = new \App\Helpers\ApiHelper();
     if (\Session::has('confirmation')) {
         $url = 'events/' . $slug . '?with[]=photos&with[]=TicketsOrder';
         if (\Auth::check()) {
             $url .= '&auth_user_id=' . \Auth::user()->id;
         }
         // Pull in single event with photos
         $events = $api->show($url, '');
         // Define events
         $events = $events['data']['event'];
         // Set default photo
         $defaultPhoto = null;
         // Use featured photo if available
         if (isset($events['featuredPhoto'])) {
             $defaultPhoto = $events['featuredPhoto'];
         }
         // Holds name of reservation
         $reserve = \Session::get('reserveInfo');
         // Holds returned success response for confirmation info
         $confirmation = \Session::get('confirmation');
         // For each reservation made, pull name and confirmation message
         for ($n = 0; $n < count($reserve); $n++) {
             $reservationConfirmation[] = ['name' => $reserve[$n]['name'], 'confirmation' => $confirmation[$n]['confirmation']];
         }
         return \View::make('events.reservation-confirmation')->with(array('events' => $events, 'defaultPhoto' => $defaultPhoto, 'reservationConfirmation' => $reservationConfirmation));
     } else {
         return \Redirect::back()->with('message', 'Something went wrong.');
     }
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function confirmation($slug)
 {
     // \Response::header('Cache-Control', 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
     $api = new ApiHelper();
     $url = 'events/' . $slug . '?with[]=photos&with[]=TicketsOrder';
     if (\Auth::check()) {
         $url .= '&auth_user_id=' . \Auth::user()->id;
     }
     // Pull in single event with photos
     $events = $api->index($url);
     // Define events
     $events = $events['data']['event'];
     if (\Session::has('quantity')) {
         foreach ($events['ticketsOrder'] as $ticketOrder) {
             if ($ticketOrder === end($events['ticketsOrder'])) {
                 $email = $ticketOrder['email'];
                 $amount = $ticketOrder['amount'];
                 $total = $ticketOrder['amount'];
             }
         }
         $quantity = \Session::get('quantity');
         return \View::make('events.confirmation')->with(array('events' => $events, 'quantity' => $quantity, 'amount' => $amount));
     } else {
         return \Redirect::route('home')->with('message', 'Confirmation page no longer available. Check your email for recipt and tickets');
     }
 }
 /**
  * testGetEventsIdSchedulesIndex (Logged out)
  * Check response status as there is nothing to test
  *
  * @depends testAuth
  * @depends testShowProfile
  * @return void
  */
 public function testGetEventsIdSchedulesIndexIn($auth, $user)
 {
     // Instanciate apihelper
     $api = new \App\Helpers\ApiHelper();
     // Pull users events with schedules
     $event = $api->index('events?filter[and][][user_id]=' . $user['data']['user']['id'] . '&with[]=schedules', []);
     $eventId = $event['data']['events'][0]['id'];
     $result = $this->actingAs($auth)->visit('events/' . $eventId . '/schedules/index')->see('Add Schedule')->seePageIs('events/' . $eventId . '/schedules/index');
 }
 /**
  * Create test tickets
  *
  * @depends testCreateEvent
  * @return $eventsTicketsUserData
  */
 public function testCreateTickets($event)
 {
     // Instanciate apihelper
     $api = new \App\Helpers\ApiHelper();
     $ticketsToMake = 6;
     for ($ticket = 0; $ticket < $ticketsToMake; $ticket++) {
         switch (true) {
             case $ticket < 3:
                 // Grab a user from
                 $user = $api->store('ticketsinventories', ['name' => 'Test ticket' . time(), 'amount' => 1.6, 'inventory' => 9999, 'user_id' => $event['user_id'], 'event_id' => $event['id'], 'is_enabled' => 1]);
                 break;
             default:
                 // Grab a user from
                 $user = $api->store('ticketsinventories', ['name' => 'Test ticket' . time(), 'amount' => 6 * 45, 'inventory' => 9999, 'user_id' => $event['user_id'], 'event_id' => $event['id'], 'is_enabled' => 1]);
                 break;
         }
     }
     $eventsTicketsUserData = $api->index('events/' . $event['slug'] . '?with[]=ticketsInventory&with[]=nextEvent');
     echo 'Creating events schedule...';
     sleep(15);
     // Refresh event data
     $eventsTicketsUserData = $api->index('events/' . $event['slug'] . '?with[]=ticketsInventory&with[]=nextEvent');
     return $eventsTicketsUserData;
 }
 /**
  * Show Friends Page
  * @return friends page view
  */
 public function showFriends()
 {
     // Shimmer the APIHelper
     $api = new \App\Helpers\ApiHelper();
     // Show current friends list
     $friend = $api->index('users/' . \Auth::user()->id . '?with[]=friends&with[]=events&with[]=friendRequests&with[]=eventInvites&with[]=ticketInventories&with[]=stripeManagedAccounts&auth_user_id=' . \Auth::user()->id);
     $user = $friend['data']['user'];
     // Shows event requests
     $eventInvite = $api->index('events/invites/' . \Auth::user()->id . '?fields[]=event.city&auth_user_id=' . \Auth::user()->id);
     $eventInvites = isset($eventInvite['data']['resource']) ? $eventInvite['data']['resource'] : [];
     // Grabs user created events for invites
     $event = $friend['data']['user']['events'];
     // Friend requests if any exist
     $friendRequest = isset($friend['data']['user']['friendRequests']) ? $friend['data']['user']['friendRequests'] : [];
     // Shows existing friends
     $friend = isset($friend['data']['user']['friends']) ? $friend['data']['user']['friends'] : [];
     // Strip fields needed for friends list
     $friend = ApiHelper::stripFieldsCollection($friend, ['id', 'email', 'username', 'firstName', 'lastName', 'avatar']);
     // Strip fields needed for user created event
     $event = ApiHelper::stripFieldsCollection($event, ['id', 'title']);
     // Strip fields needed for friend request
     $friendRequest = ApiHelper::stripFieldsCollection($friendRequest, ['id', 'email', 'username', 'firstName', 'lastName', 'avatar']);
     return View::make('accounts.friends')->with(['friend' => $friend, 'eventInvites' => $eventInvites, 'user' => $user, 'event' => $event, 'friendRequest' => $friendRequest]);
 }
 public function oathCallback(Request $request, $provider)
 {
     // Check if user is signed in
     if (!\Auth::check()) {
         // Return fail message
         return Redirect::route('home')->with('fail_message', 'You must be signed in to make this request');
     }
     // Check if code is set
     if (!isset($request::all()['code'])) {
         return Redirect::route('payment')->with('fail_message', 'There was a problem creating your account. Please try again later');
     }
     // Define userId
     $userId = \Auth::user()->id;
     // Define connected user data with return authorization
     $connectedUser = Socialize::driver($provider)->user();
     // Define create data
     $acctId = $connectedUser->id;
     $meta = json_encode($connectedUser);
     // Insanciate the APIHelper
     $api = new \App\Helpers\ApiHelper();
     // Save managed account to API
     $stripeManagedAccount = $api->store('users/createManaged', ['user_id' => $userId, 'acct_id' => $acctId, 'meta' => $meta]);
     // Check success
     if ($stripeManagedAccount['success'] !== true) {
         return Redirect::route('payment')->with(['fail_message' => $stripeManagedAccount['error']]);
     }
     // Return success
     return Redirect::route('payment')->with(['success_message' => 'Account connected successfully!']);
 }