/** * 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; }
/** * @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; }
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; }
/** * 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; }
/** * 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 user profile * * @param string $username user username (optional) */ public function showProfile($username = null) { // Incandescence the APIHelper $api = new \App\Helpers\ApiHelper(); // Is this profile being called publicly or privately $isAccessedPublicly = empty($username) ? false : true; // Abort if we are public and there is no username or its empty if ($isAccessedPublicly && empty($username)) { // Show the not found page abort(404); } // Initiate created events by user $eventsCreatedByUser = []; // Get user info if ($isAccessedPublicly) { $url = 'users?filter[and][][username]=' . $username . '&with[]=updates&with[]=ticketInventories&with[]=friends&with[]=friendRequests&with[]=stripeManagedAccounts'; if (\Auth::check()) { $url .= '&auth_user_id=' . \Auth::user()->id; } // Query by username $user = $api->index($url); // Set user data $user = isset($user['data']['users'][0]) ? $user['data']['users'][0] : []; // If user exists if (!empty($user)) { $eventUrl = 'events?filter[and][][user_id]=' . $user['id'] . '&with[]=times&filter[and][][is_published]=1&filter[and][][is_banned]=0&with[]=TicketsInventory'; if (\Auth::check()) { $eventUrl .= '&auth_user_id=' . \Auth::user()->id; } $eventsCreatedByUser = $api->index($eventUrl); $attendingUrl = 'events/attending/' . $user['id']; if (\Auth::check()) { $attendingUrl .= '?auth_user_id=' . \Auth::user()->id; } // Get events that this user is attending $userEventsTimesAttending = $api->index($attendingUrl); // Set events that this user is attending $userEventsTimesAttending = isset($userEventsTimesAttending['data']['times']) ? $userEventsTimesAttending['data']['times'] : []; $myEventsformatted = []; $isFriend = false; $isRequested = false; if (isset($user['friendRequests']) && \Auth::user()) { // Indexes and iterates through friend requests foreach ($user['friendRequests'] as $index => $checkRequested) { // If friend request id and auth id match, will display proper message in view if ($checkRequested['id'] === \Auth::user()->id) { $isRequested = true; // Once match is found, stops iteration break; } } } if (isset($userEventsTimesAttending)) { foreach ($userEventsTimesAttending as $time) { $myEventsformatted[] = ['title' => isset($time['event']['title']) ? $time['event']['title'] : null, 'start' => isset($time['start']) ? $time['start'] : null, 'end' => isset($time['end']) ? $time['end'] : null, 'url' => route('events.show', ['slug' => isset($time['event']['slug']) ? $time['event']['slug'] : null])]; } } // JSON encode $myEventsformatted = addslashes(json_encode($myEventsformatted)); } } else { // Query by id of logged in user $user = $api->index('users?filter[and][][id]=' . Auth::user()->id . '&with[]=updates&with[]=ticketInventories&with[]=stripeManagedAccounts&auth_user_id=' . \Auth::user()->id); // Set user data $user = isset($user['data']['users'][0]) ? $user['data']['users'][0] : []; // If user exists if (!empty($user)) { $eventsCreatedByUser = $api->index('events?filter[and][][user_id]=' . \Auth::user()->id . '&with[]=times&filter[and][][is_published]=1&filter[and][][is_banned]=0&with[]=TicketsInventory&auth_user_id=' . \Auth::user()->id); // Get events that this user is attending $userEventsTimesAttending = $api->index('events/attending/' . \Auth::user()->id . '?auth_user_id=' . \Auth::user()->id); // Set events that this user is attending $userEventsTimesAttending = isset($userEventsTimesAttending['data']['times']) ? $userEventsTimesAttending['data']['times'] : []; $myEventsformatted = []; if (isset($userEventsTimesAttending)) { foreach ($userEventsTimesAttending as $time) { $myEventsformatted[] = ['title' => isset($time['event']['title']) ? $time['event']['title'] : null, 'start' => isset($time['start']) ? $time['start'] : null, 'end' => isset($time['end']) ? $time['end'] : null, 'url' => route('events.show', ['slug' => isset($time['event']['slug']) ? $time['event']['slug'] : null])]; } } // JSON encode $myEventsformatted = addslashes(json_encode($myEventsformatted)); } } // Make sure we have data if (empty($user)) { // Show the not found page abort(404); } $friendPost = []; if (isset($user['friends']) && \Auth::user()) { // Indexes and iterates through public user friends foreach ($user['friends'] as $index => $checkFriend) { // If auth user id and friend id matches, will display proper message in view if ($checkFriend['id'] === \Auth::user()->id) { $isFriend = true; $friendPost = $checkFriend; // Once match is found, stops iteration break; } } } $eventsCreatedByUser = isset($eventsCreatedByUser['data']['events']) ? $eventsCreatedByUser['data']['events'] : []; $url = 'events?filter[and][][isSponsored]=1&fields[]=id&fields[]=title' . '&fields[]=description&fields[]=slug&fields[]=isSponsored' . '&fields[]=featuredPhoto&limit=3&filter[and][][is_published]=1' . '&filter[and][][is_banned]=0'; if (auth::check()) { $url .= '&auth_user_id=' . \Auth::user()->id; } // Get 3 sponsored events $sponsoredEvents = $api->index($url); // Give events a short variable to work with $sponsoredEvents = isset($sponsoredEvents['data']['events']) ? $sponsoredEvents['data']['events'] : []; // Get upload settings for evaporate.js $uploadSettings = $api->index('settings/upload'); $uploadSettings = isset($uploadSettings['data']) ? $uploadSettings['data'] : []; // Return view return View::make('accounts.profile')->with(array('friendPost' => isset($friendPost) ? $friendPost : [], 'isFriend' => isset($isFriend) ? $isFriend : false, 'isRequested' => isset($isRequested) ? $isRequested : false, 'isAccessedPublicly' => $isAccessedPublicly, 'myEventsformatted' => $myEventsformatted, 'user' => $user, 'eventsCreatedByUser' => $eventsCreatedByUser, 'userEventsTimesAttending' => $userEventsTimesAttending, 'uploadSettings' => $uploadSettings, 'sponsoredEvents' => $sponsoredEvents)); }