public function index()
 {
     $perPage = 10;
     $expiredEvents = $this->eventRepository->getPastEvents($perPage);
     //find countries,authors,and categories to display in search form
     $countries = [0 => trans('word.choose_country')] + $this->countryRepository->getAll()->lists('name_' . getLocale(), 'id');
     $categories = [0 => trans('word.choose_category')] + $this->categoryRepository->getEventCategories()->lists('name_' . getLocale(), 'id');
     $authors = [0 => trans('word.choose_author')] + $this->userRepository->getRoleByName('author')->lists('name_' . getLocale(), 'id');
     // find selected form values
     $search = trim(Input::get('search'));
     $category = Request::get('category');
     $author = Request::get('author');
     $country = Request::get('country');
     $expired = Request::get('past');
     $this->title = trans('word.events');
     // if the form is selected
     // perform search
     if (!empty($search) || !empty($category) || !empty($author) || !empty($country)) {
         $events = $this->eventRepository->getAll()->where(function ($query) use($search, $category, $author, $country) {
             if (!empty($search)) {
                 $query->where('title_ar', 'LIKE', "%{$search}%")->orWhere('title_en', 'LIKE', "%{$search}%");
             }
             if (!empty($category)) {
                 $query->where('category_id', $category);
             }
             if (!empty($author)) {
                 $query->where('user_id', $author);
             }
             if (!empty($country)) {
                 $locations = $this->countryRepository->findById($country)->locations()->lists('id');
                 $query->whereIn('location_id', $locations);
             }
         })->orderBy('date_start', 'ASC')->orderBy('created_at', 'ASC')->paginate($perPage);
     } elseif (isset($expired) && $expired == 'true') {
         // Past Events
         $this->title = trans('word.expired_events');
         $events = $expiredEvents;
     } else {
         $events = $this->eventRepository->getNonExpiredEvents($perPage);
     }
     $eventCategories = $this->categoryRepository->getEventCategories()->get();
     $tags = $this->tagRepository->getEventTags();
     $this->render('site.events.index', compact('events', 'authors', 'categories', 'countries', 'search', 'category', 'author', 'country', 'eventCategories', 'tags', 'expiredEvents'));
 }
 public function sendActivationLink()
 {
     $userId = Input::get('user_id');
     $user = $this->userRepository->findById($userId);
     if ($user) {
         $this->service->processActivation($user);
         return Redirect::back()->with('success', trans('auth.alerts.account_activation_link_sent'));
     }
     return Redirect::back()->with('error', trans('auth.alerts.invalid_user'));
 }