public function getMyBusiness() { if (Auth::check()) { $businesses = UserBusiness::getAllBusinessIdByOwner(Helper::userId()); $my_terminals = TerminalUser::getTerminalAssignement(Helper::userId()); $assigned_businesses = []; if (count($my_terminals) > 0) { foreach ($my_terminals as $terminal) { $bid = Business::getBusinessIdByTerminalId($terminal['terminal_id']); if (!isset($assigned_businesses[$bid])) { $assigned_businesses[$bid] = ['business_id' => $bid, 'name' => Business::name($bid), 'terminals' => [['terminal_id' => $terminal['terminal_id'], 'name' => Terminal::name($terminal['terminal_id'])]]]; } else { array_push($assigned_businesses[$bid]['terminals'], ['terminal_id' => $terminal['terminal_id'], 'name' => Terminal::name($terminal['terminal_id'])]); } } } if (count($businesses) > 0) { $business = $businesses[0]; $business_id = $business->business_id; unset($assigned_businesses[$business->business_id]); $first_service = Service::getFirstServiceOfBusiness($business_id); $terminals = Terminal::getTerminalsByServiceId($first_service->service_id); $first_terminal = count($terminals) > 0 ? $terminals[0]['terminal_id'] : null; return View::make('business.my-business')->with('business_id', $business_id)->with('assigned_businesses', $assigned_businesses)->with('first_terminal', $first_terminal); } else { return View::make('business.my-business')->with('assigned_businesses', $assigned_businesses); } } else { return Redirect::to('/'); } }
/** * Renders process queue page * @param $service_id */ public function getTerminal($terminal_id) { if (!TerminalUser::isCurrentUserAssignedToTerminal($terminal_id)) { return Redirect::back(); } return View::make('process-queue.process-queue')->with('body', 'processq')->with('terminal_id', $terminal_id)->with('service_id', Terminal::serviceId($terminal_id))->with('terminal_name', Terminal::name($terminal_id))->with('business_id', Business::getBusinessIdByTerminalId($terminal_id))->with('business_name', Business::getBusinessNameByTerminalId($terminal_id)); }