/**
  * 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;
 }
 public function testGetEvents()
 {
     // Instanciate apihelper
     $api = new \App\Helpers\ApiHelper();
     // Grab a user from
     $events = $api->index('events?filter[and][][is_published]=1&filter[and][][user_id]=1');
     $events = $events['data']['events'];
     return $events;
 }
 /**
  * Get users profile
  *
  * @return $user
  */
 public function testShowProfile()
 {
     // Instanciate apihelper
     $api = new \App\Helpers\ApiHelper();
     // Grab a user from
     $user = $api->show('users', '1');
     // Set usersname
     $username = $user['data']['user']['username'];
     // Grab selected user via website
     $result = $this->visit('users/' . $username)->see($user['data']['user']['id'])->see($user['data']['user']['timeZoneId'])->see($user['data']['user']['firstName'])->see($user['data']['user']['lastName']);
     return $user;
 }
 /**
  * Test testFormOpen()
  *
  * @return void
  */
 public function testFormOpen()
 {
     // Instantiate api helper
     $api = new \App\Helpers\ApiHelper();
     // Grab an event from
     $event = $api->index('events');
     $event = $event['data']['events'][0];
     // Set event id
     $eventId = $event['id'];
     // Set token to pass with form
     $token = Session::getToken();
     // Post schedule with data
     $result = $this->call('POST', 'events/schedules/create/' . $eventId, ['_token' => $token, 'startDate' => '2018-11-11', 'startTime' => '20:00:00', 'endDate' => '2018-11-11', 'endTime' => '21:00:00', 'timeZoneId' => '6']);
     // Check Response for post to be a 302
     $this->assertResponseStatus(302);
 }
 public function home()
 {
     Config::set('global.pageLoaderDisplay', true);
     // Instantiate the APIHelper
     $api = new \App\Helpers\ApiHelper();
     $featuredUrl = 'events/featured/carousel?filter[and][][times.end]=date&with[]=times&with[]=ticketsInventory';
     $featuredTagsUrl = 'events/featured/tags';
     $tagsIsFeaturedUrl = 'events/featured/tags/all?filter[and][][times.end]=date&filter[and][][is_published]=1&with[]=times&fields[]=isSponsored&fields[]=slug&fields[]=title&fields[]=featuredPhoto&fields[]=city&fields[]=state&fields[]=description&fields[]=times';
     if (\Auth::check()) {
         $featuredUrl .= '&auth_user_id=' . \Auth::user()->id;
         $featuredTagsUrl .= '?auth_user_id=' . \Auth::user()->id;
         $tagsIsFeaturedUrl .= '&auth_user_id=' . \Auth::user()->id;
     }
     // Get events that have is_featured
     $eventsIsFeatured = $api->index($featuredUrl);
     $eventsIsFeatured = isset($eventsIsFeatured['data']['events']) ? $eventsIsFeatured['data']['events'] : [];
     $eventsFeaturedTags = $api->index($featuredTagsUrl);
     // Get tags that have is_featured and postheir perspective events
     $eventsTagsIsFeatured = $api->index($tagsIsFeaturedUrl);
     $eventsTagsIsFeatured = isset($eventsTagsIsFeatured['data']['all']) ? $eventsTagsIsFeatured['data']['all'] : [];
     // State abbreviations to be used in carousel location label
     $stateAbbreviations = ['Alabama' => 'AL', 'Alaska' => 'AK', 'Arizona' => 'AZ', 'Arkansas' => 'AR', 'California' => 'CA', 'Colorado' => 'CO', 'Connecticut' => 'CT', 'Delaware' => 'DE', 'Florida' => 'FL', 'Georgia' => 'GA', 'Hawaii' => 'HI', 'Idaho' => 'ID', 'Illinois' => 'IL', 'Indiana' => 'IN', 'Iowa' => 'IA', 'Kansas' => 'KS', 'Kentucky' => 'KY', 'Louisiana' => 'LA', 'Maine' => 'ME', 'Maryland' => 'MD', 'Massachusetts' => 'MA', 'Michigan' => 'MI', 'Minnesota' => 'MN', 'Mississippi' => 'MS', 'Missouri' => 'MO', 'Montana' => 'MT', 'Nebraska' => 'NE', 'Nevada' => 'NV', 'New Hampshire' => 'NH', 'New Jersey' => 'NJ', 'New Mexico' => 'NM', 'New York' => 'NY', 'North Carolina' => 'NC', 'North Dakota' => 'ND', 'Ohio' => 'OH', 'Oklahoma' => 'OK', 'Oregon' => 'OR', 'Pennsylvania' => 'PA', 'Rhode Island' => 'RI', 'South Carolina' => 'SC', 'South Dakota' => 'SD', 'Tennessee' => 'TN', 'Texas' => 'TX', 'Utah' => 'UT', 'Vermont' => 'VT', 'Virginia' => 'VA', 'Washington' => 'WA', 'West Virginia' => 'WV', 'Wisconsin' => 'WI', 'Wyoming' => 'WY'];
     return \View::make('pages.home', array('eventsIsFeatured' => $eventsIsFeatured, 'eventsTagsIsFeatured' => $eventsTagsIsFeatured, 'stateAbbreviations' => $stateAbbreviations, 'metaTitle' => 'SUARAY - Discover Fun Events'));
 }
 /**
  * Shows tickets inventory index page
  *
  * @param  string  $slug
  * @return Response
  */
 public function showIndex($slug)
 {
     // Instantiate api helper
     $api = new \App\Helpers\ApiHelper();
     $url = 'events/' . $slug . '?with[]=ticketsInventory';
     if (\Auth::check()) {
         $url .= '&auth_user_id=' . \Auth::user()->id;
     }
     // Grabs information needed to pull in tickets for event
     $events = $api->index($url);
     if (empty($events['data']['event'])) {
         abort(404);
     } else {
         // Define events as variable to hold the events
         $event = $events['data']['event'];
     }
     if (\Auth::user()->id != $event['userId']) {
         abort(401);
     }
     // Check if Auth user has managed account
     $managed = $api->show('users', \Auth::user()->id . '?with[]=stripeManagedAccounts&auth_user_id=' . \Auth::user()->id);
     $managed = isset($managed['data']['user']['stripeManagedAccounts'][0]) ? $managed['data']['user']['stripeManagedAccounts'][0] : [];
     // Return the tickets index view
     return View::make('accounts.dashboard.tickets.index')->with(['event' => $event, 'managed' => $managed]);
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($event, $id)
 {
     $api = new \App\Helpers\ApiHelper();
     $url = 'events/' . $event . '/photos/' . $id;
     if (\Auth::check()) {
         $url .= '?auth_user_id=' . \Auth::user()->id;
     }
     $photos = $api->destroy($url, '');
     if ($photos['success'] === true) {
         return \Redirect::back()->with('success_message', 'Image successfully deleted!
   ');
     } else {
         return \Redirect::back()->with('success_message', 'Image not found, must be deleted!
   ');
     }
 }
 public function show($slug)
 {
     $api = new \App\Helpers\ApiHelper();
     //Checking for user auth
     $user = \Auth::user();
     $url = 'events/' . $slug . '?with[]=reviews';
     if (\Auth::check()) {
         $url .= '&auth_user_id=' . $user;
     }
     $events = $api->show($url, '');
     $events = $events['data']['event']['reviews'];
     //If statement to determine whether or snot user is logged in to post
     if (\Auth::check()) {
         // Getting user id
         $id = $user->id;
         // Insanciate the APIHelper
         $api = new \App\Helpers\ApiHelper();
         // grab user information
         $eventsAttending = $api->index('events/' . $id . '?with[]=user&with[]=photos&auth_user_id=' . \Auth::user()->id);
         $eventsAttending = $eventsAttending['data'];
         // User must be logged in to post review
     } else {
         return \Redirect::guest(\URL::action('AccountsController@showLogin'));
     }
     return \View::make('events.event-ratings')->with(['eventsAttending' => $eventsAttending, 'slug' => $slug, 'events' => $events]);
 }