/** * Display a listing of the resource. * @return \Illuminate\Http\Response */ public function index() { \Nexus\Helpers\ActivityHelper::updateActivity(\Auth::user()->id, "Checking out <em>who else is online</em>", action('Nexus\\ActivityController@index')); $activities = \Nexus\Helpers\ActivityHelper::recentActivities(); $breadcrumbs = \Nexus\Helpers\BreadcrumbHelper::breadcumbForUtility('Who is Online'); return view('activities.index', compact('activities', 'breadcrumbs')); }
/** * Display a listing of the resource. * * @return Response */ public function index() { $users = \Nexus\User::select('username')->orderBy('username', 'asc')->get(); \Nexus\Helpers\ActivityHelper::updateActivity(\Auth::user()->id, "Viewing list of Users", action('Nexus\\UserController@index')); $breadcrumbs = \Nexus\Helpers\BreadcrumbHelper::breadcumbForUtility('Users'); return view('users.index', compact('users', 'breadcrumbs')); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $trashedSections = \Nexus\Section::onlyTrashed()->where('user_id', \Auth::user()->id)->with('trashedTopics')->get(); // add trashed sections which are children of moderated sections which are not moderated by the user // @todo: can this be a query? foreach (\Auth::user()->sections as $moderatedSections) { $unmoderatedSections = $moderatedSections->sections()->onlyTrashed()->with('trashedTopics')->where('user_id', '!=', \Auth::user()->id)->get(); foreach ($unmoderatedSections as $unmoderatedSection) { $trashedSections->push($unmoderatedSection); } } $trashedSections = $trashedSections->sortByDesc('deleted_at'); $trashedTopics = \Auth::user()->trashedTopics; $breadcrumbs = \Nexus\Helpers\BreadcrumbHelper::breadcumbForUtility('Your Archive'); $destinationSections = \Auth::user()->sections()->get(); return view('restore.index', compact('trashedSections', 'trashedTopics', 'breadcrumbs', 'destinationSections')); }
/** * Displays a list of messages sent to the logged in user * @todo - generate $activeUsers array from a list of active users * @return Response */ public function index($selected = null) { $allMessages = \Nexus\Message::with('user')->with('author')->where('user_id', \Auth::user()->id)->orderBy('id', 'desc')->get()->all(); $messages = array_slice($allMessages, 5); $recentMessages = array_reverse(array_slice($allMessages, 0, 5)); $recentActivities = \Nexus\Helpers\ActivityHelper::recentActivities(); $activeUsers = array(); foreach ($recentActivities as $activity) { if (\Auth::user()->id != $activity['user_id']) { $activeUsers[$activity['user_id']] = $activity->user->username; } } // mark all messages as read \Nexus\Message::where('user_id', \Auth::user()->id)->update(['read' => true]); \Nexus\Helpers\ActivityHelper::updateActivity(\Auth::user()->id, "Viewing <em>Inbox</em>", action('Nexus\\MessageController@index')); $breadcrumbs = \Nexus\Helpers\BreadcrumbHelper::breadcumbForUtility('Inbox'); return view('messages.index')->with(compact('messages', 'recentMessages', 'activeUsers', 'selected', 'breadcrumbs')); }
/** * perform a search against all the posts and * return some results * @todo - ignore word order * @todo - remove stop words * @todo - deal with exact phrases */ public function find($text) { $phraseSearch = false; $displaySearchResults = true; // if text is ^"(.*)"$ or ^'(.*)'$ then we are searching for a phrase $pattern = <<<'pattern' /^['|"](.*)['|"]$/ pattern; $matches = false; preg_match($pattern, $text, $matches); if (!$matches) { // set initial results as nothing $results = false; // look for all the words $rawSearchTerms = explode(' ', $text); $searchTerms = array(); // remove stop words here foreach ($rawSearchTerms as $word) { if (!in_array(strtolower($word), self::$stopWords)) { $searchTerms[] = $word; } } // dd($searchTerms); foreach ($searchTerms as $word) { // remove unwanted characters from the start and end // @todo this does not remove multiple unwanted commas etc $word = trim($word); if (strlen($word) !== 0) { if ($results) { $results = $results->where('text', 'like', "%{$word}%"); } else { // first where $results = \Nexus\Post::where('text', 'like', "%{$word}%"); } } } } else { $phrase = trim($matches[1]); $results = \Nexus\Post::where('text', 'like', "%{$phrase}%"); } if ($results) { $results->orderBy('time', 'desc'); } \Nexus\Helpers\ActivityHelper::updateActivity(\Auth::user()->id, "Searching", action('Nexus\\SearchController@index')); $breadcrumbs = \Nexus\Helpers\BreadcrumbHelper::breadcumbForUtility('Search'); return view('search.results', compact('results', 'breadcrumbs', 'text', 'displaySearchResults')); }
public function latest() { $heading = 'Latest Posts'; $lead = "The most recent posts from across Nexus"; $topics = $this::recentTopics(); $breadcrumbs = \Nexus\Helpers\BreadcrumbHelper::breadcumbForUtility($heading); return view('topics.unread', compact('topics', 'heading', 'lead', 'breadcrumbs')); }