osb/app/Http/Controllers/UserHomeController.php

57 lines
1.1 KiB
PHP
Raw Normal View History

2018-05-20 22:53:14 +10:00
<?php
namespace App\Http\Controllers;
2018-07-13 14:53:44 +10:00
use Illuminate\Support\Facades\Auth;
2018-08-01 17:09:38 +10:00
use App\Models\Invoice;
use App\User;
2018-07-13 14:53:44 +10:00
2018-05-20 22:53:14 +10:00
class UserHomeController extends Controller
{
public function __construct()
{
$this->middleware('auth');
}
2018-08-01 17:09:38 +10:00
public function invoice(Invoice $o)
{
return View('invoice',['o'=>$o]);
}
2018-05-20 22:53:14 +10:00
public function home()
{
2018-07-13 14:53:44 +10:00
switch (Auth::user()->role()) {
2018-07-31 14:11:00 +10:00
case 'customer':
2018-07-17 14:10:40 +10:00
return View('userhome',['o'=>Auth::user()]);
2018-07-13 14:53:44 +10:00
2018-07-31 14:11:00 +10:00
case 'reseller':
2018-07-17 14:10:40 +10:00
return View('resellerhome',['o'=>Auth::user()]);
2018-07-13 14:53:44 +10:00
2018-07-31 14:11:00 +10:00
case 'wholesaler':
2018-07-17 14:10:40 +10:00
return View('resellerhome',['o'=>Auth::user()]);
2018-07-13 14:53:44 +10:00
default:
2018-07-31 14:11:00 +10:00
abort(500,'Unknown role: '.Auth::user()->role());
2018-07-13 14:53:44 +10:00
}
2018-05-20 22:53:14 +10:00
}
2018-07-16 15:06:43 +10:00
/**
* 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));
}
2018-08-01 17:09:38 +10:00
public function User(User $o)
{
// @todo Check authorised to see this account.
return View('userhome',['o'=>$o]);
}
2018-05-20 22:53:14 +10:00
}