osb/app/Http/Controllers/UserHomeController.php

63 lines
1.3 KiB
PHP
Raw Normal View History

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-01 07:09:38 +00:00
use App\Models\Invoice;
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');
}
2018-08-01 07:09:38 +00:00
public function invoice(Invoice $o)
{
return View('invoice',['o'=>$o]);
}
2018-08-01 13:29:16 +00:00
public function invoice_pdf(Invoice $o)
{
return PDF::loadView('invoice', ['o'=>$o])->stream(sprintf('%s.pdf',$o->invoice_account_id));
}
2018-05-20 12:53:14 +00:00
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-07-17 04:10:40 +00:00
return View('userhome',['o'=>Auth::user()]);
2018-07-13 04:53:44 +00:00
2018-07-31 04:11:00 +00:00
case 'reseller':
2018-07-17 04:10:40 +00:00
return View('resellerhome',['o'=>Auth::user()]);
2018-07-13 04:53:44 +00:00
2018-07-31 04:11:00 +00:00
case 'wholesaler':
2018-07-17 04:10:40 +00:00
return View('resellerhome',['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
/**
* 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
public function User(User $o)
{
// @todo Check authorised to see this account.
return View('userhome',['o'=>$o]);
}
2018-05-20 12:53:14 +00:00
}