/**
  * @param $eventId EventID
  * @return \Illuminate\Http\RedirectResponse
  * Unsubscribe a user
  */
 public function unsubscribe($eventId)
 {
     $userId = Auth::user()->id;
     $event = $this->eventRepository->findById($eventId);
     $subscription = $this->subscriptionRepository->findByEvent($userId, $eventId);
     if (!$event) {
         return Redirect::action('EventsController@show', $eventId)->with('warning', trans('word.system_error'));
     }
     // If event is Expired
     if ($this->eventRepository->eventExpired($event->date_start)) {
         return Redirect::action('EventsController@show', $eventId)->with('warning', trans('word.event_expired'));
     }
     // if event is currently going on
     //        if ( $this->eventRepository->ongoingEvent($event->date_start, $event->date_end) ) {
     //
     //            return Redirect::action('EventsController@show', $eventId)->with('warning', trans('general.event_ongoing'));
     //        }
     if ($subscription) {
         $subscriber = new Subscriber($subscription);
         $subscriber = $subscriber->unsubscribe();
         if ($subscriber->messages->has('errors')) {
             // redirect with first error as an array
             return Redirect::action('EventsController@index')->with('errors', [$subscriber->messages->first('errors')]);
         } else {
             // If no errors occured while subscription process
             return Redirect::action('EventsController@index')->with('success', trans('general.unsubscribed'));
         }
     }
     return Redirect::action('EventsController@index')->with('success', trans('general.subscription.unsubscribed_fail'));
 }
 /**
  * @param $id
  * Lands on this page when link from email is clicked
  */
 public function getPayment($id)
 {
     $payment = $this->paymentRepository->findByToken(Input::get('token'));
     if (!$payment) {
         return Redirect::action('EventsController@index')->with('error', trans('word.token_expired'));
     }
     $event = $this->eventRepository->findById($id);
     if ($this->eventRepository->eventExpired($event->date_start)) {
         return Redirect::action('EventsController@index')->with('error', trans('word.event_expired'));
     }
     $user = Auth::user();
     $country = $this->processCountry($event);
     $subscription = $this->subscriptionRepository->findByEvent($user->id, $event->id);
     $eventPrice = $event->getPriceByCountryAndType($country->id, $subscription->registration_type)->first();
     $this->render('site.events.payment-options', compact('event', 'payment', 'country', 'eventPrice', 'country'));
 }
 /**
  * @param $id EventID
  * @return \Illuminate\Http\RedirectResponse
  * Users can click a button to reorganize specific event
  */
 public function reorganizeEvents($id)
 {
     $user = Auth::user();
     //check whether seats are empty
     $event = $this->eventRepository->findById($id);
     $eventExpired = $this->eventRepository->eventExpired($event->date_start);
     if ($eventExpired) {
         if (!$event->reorganize->contains($user->id)) {
             $event->reorganize()->attach($user, ['created_at' => Carbon::now()]);
         }
     }
     return Redirect::action('EventsController@show', $id)->with('success', trans('general.requested_admin'));
 }