2018-05-20 12:53:14 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
2018-07-13 04:53:44 +00:00
|
|
|
use Illuminate\Support\Facades\Auth;
|
2018-08-23 05:17:26 +00:00
|
|
|
use App\Models\{Invoice,Service};
|
2018-08-01 07:09:38 +00:00
|
|
|
use App\User;
|
2018-08-01 13:29:16 +00:00
|
|
|
use PDF;
|
2018-07-13 04:53:44 +00:00
|
|
|
|
2018-05-20 12:53:14 +00:00
|
|
|
class UserHomeController extends Controller
|
|
|
|
{
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
$this->middleware('auth');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function home()
|
|
|
|
{
|
2018-07-13 04:53:44 +00:00
|
|
|
switch (Auth::user()->role()) {
|
2018-07-31 04:11:00 +00:00
|
|
|
case 'customer':
|
2018-08-08 23:33:51 +00:00
|
|
|
return View('u.home',['o'=>Auth::user()]);
|
2018-07-13 04:53:44 +00:00
|
|
|
|
2018-07-31 04:11:00 +00:00
|
|
|
case 'reseller':
|
2018-08-08 23:33:51 +00:00
|
|
|
return View('r.home',['o'=>Auth::user()]);
|
2018-07-13 04:53:44 +00:00
|
|
|
|
2018-07-31 04:11:00 +00:00
|
|
|
case 'wholesaler':
|
2018-08-08 23:33:51 +00:00
|
|
|
return View('r.home',['o'=>Auth::user()]);
|
2018-07-13 04:53:44 +00:00
|
|
|
|
|
|
|
default:
|
2018-07-31 04:11:00 +00:00
|
|
|
abort(500,'Unknown role: '.Auth::user()->role());
|
2018-07-13 04:53:44 +00:00
|
|
|
}
|
2018-05-20 12:53:14 +00:00
|
|
|
}
|
2018-07-16 05:06:43 +00:00
|
|
|
|
2018-08-23 05:17:26 +00:00
|
|
|
public function invoice(Invoice $o)
|
|
|
|
{
|
|
|
|
return View('u.invoice',['o'=>$o]);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function invoice_pdf(Invoice $o)
|
|
|
|
{
|
|
|
|
return PDF::loadView('u.invoice', ['o'=>$o])->stream(sprintf('%s.pdf',$o->invoice_account_id));
|
|
|
|
}
|
|
|
|
|
2018-07-16 05:06:43 +00: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 07:09:38 +00:00
|
|
|
|
2018-08-23 05:17:26 +00:00
|
|
|
public function service(Service $o)
|
|
|
|
{
|
|
|
|
return View('u.service',['o'=>$o]);
|
|
|
|
}
|
|
|
|
|
2018-08-01 07:09:38 +00:00
|
|
|
public function User(User $o)
|
|
|
|
{
|
|
|
|
// @todo Check authorised to see this account.
|
2018-08-08 23:33:51 +00:00
|
|
|
return View('u.home',['o'=>$o]);
|
2018-08-01 07:09:38 +00:00
|
|
|
}
|
2018-05-20 12:53:14 +00:00
|
|
|
}
|