middleware('auth'); } /** * Logged in users home page * * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function home(): View { switch (Auth::user()->role()) { case 'customer': return View('u.home',['o'=>Auth::user()]); case 'reseller': return View('r.home',['o'=>Auth::user()]); case 'wholesaler': return View('r.home',['o'=>Auth::user()]); default: abort(500,'Unknown role: '.Auth::user()->role()); } } /** * Render a specific invoice for the user * * @param Invoice $o * @return View */ public function invoice(Invoice $o): View { return View('u.invoice',['o'=>$o]); } /** * Return the invoice in PDF format, ready to download * * @param Invoice $o * @return mixed */ public function invoice_pdf(Invoice $o) { return PDF::loadView('u.invoice', ['o'=>$o])->stream(sprintf('%s.pdf',$o->invoice_account_id)); } /** * Helper to redirect to the old site, when functions are not available in this one. * * @param $type * @param $action * @param $id * @return void * @deprecated @todo Remove once all functions added */ public function oldsite($type,$action,$id) { abort(307,sprintf('http://www.graytech.net.au/u/%s/%s/%s',$type,$action,$id)); } /** * Return details on the users service * * @param Service $o * @return View */ public function service(Service $o): View { return View('u.service',['o'=>$o]); foreach ([ sprintf('u.service.%s.%s',$o->type->type,$o->status), sprintf('u.service.%s',$o->status), ] as $v) if (view()->exists($v)) return View($v,['o'=>$o]); // View doesnt exist, fall back to default view return View('u.service',['o'=>$o]); } public function User(User $o) { // @todo Check authorised to see this account. return View('u.home',['o'=>$o]); } }