public function get_va($id) { //Is someone trying to pass something other than an integer? if (!is_numeric($id)) { return Redirect::route('console'); } $va = User::findOrFail($id); //Do we have a banner? //Ugh laravel gets mad when we don't so let's just set it as empty for now. $banner = ''; if ($va->banner) { $banner = User::getBannerUrl($va->cid); } //Pull our banner directory from settings $banner_maxwidth = Setting::fetch('banner_maxwidth'); $banner_maxheight = Setting::fetch('banner_maxheight'); //Pull our audit log $audit_log = AuditLog::where('va', '=', $va->cid)->orderBy('created_at', 'DESC')->get(); //Pull our tickets created by this VA $tickets = Ticket::where('vid', '=', $id)->orderBy('updated_at', 'DESC')->get(); //Pull our hidden categories $hiddenCategories = Category::where('hidden', '=', 1)->get(); //Create an array of hidden category ids $hiddenCategoryIds = array(); foreach ($hiddenCategories as $hiddenCategory) { $hiddenCategoryIds[] = $hiddenCategory->id; } $categories = $va->categories; $categories = explode(',', $categories); //Get rid of the empty array pair array_pop($categories); $currentHiddenCategories = array(); foreach ($categories as $category) { if (in_array($category, $hiddenCategoryIds)) { $currentHiddenCategories[] = $category; } } //Get all of our non hidden categories $allcategories = Category::where('hidden', '=', 0)->get(); //Max categories $max_categories = Setting::fetch('max_categories'); //Pull our email templates $emailTemplates = EmailTemplate::where('author', '=', Auth::consoleuser()->get()->cid)->orderBy('name', 'DESC')->get(); $sharedEmailTemplates = EmailTemplate::where('author', '!=', Auth::consoleuser()->get()->cid)->where('public', '=', '1')->orderBy('name', 'DESC')->get(); return View::make('console.va')->with(array('va' => $va, 'banner' => $banner, 'audit_log' => $audit_log, 'banner_maxwidth' => $banner_maxwidth, 'banner_maxheight' => $banner_maxheight, 'tickets' => $tickets, 'emailTemplates' => $emailTemplates, 'sharedEmailTemplates' => $sharedEmailTemplates, 'hiddenCategories' => $hiddenCategories, 'currentHiddenCategories' => $currentHiddenCategories, 'categories' => $allcategories, 'currentCategories' => $categories, 'max_categories' => $max_categories)); }