Updates to login home
This commit is contained in:
@@ -44,7 +44,7 @@ class AdminHomeController extends Controller
|
||||
try {
|
||||
if ($key == 'site_logo' AND $value instanceof UploadedFile)
|
||||
{
|
||||
$path = $value->storePubliclyAs('site/'.config('SITE_SETUP')->id,$value->getClientOriginalName());
|
||||
$path = $value->storeAs('site/'.config('SITE_SETUP')->id,$value->getClientOriginalName(),'public');
|
||||
|
||||
SiteDetails::updateOrCreate([
|
||||
'site_id'=>config('SITE_SETUP')->id,
|
||||
|
@@ -6,13 +6,18 @@ use Auth;
|
||||
|
||||
class ResellerServicesController extends Controller
|
||||
{
|
||||
public function accounts()
|
||||
{
|
||||
return ['data'=>Auth::user()->all_accounts()->values()];
|
||||
}
|
||||
|
||||
public function agents()
|
||||
{
|
||||
return ['data'=>Auth::user()->all_agents()->values()];
|
||||
}
|
||||
|
||||
public function accounts()
|
||||
public function clients()
|
||||
{
|
||||
return ['data'=>Auth::user()->all_accounts()->values()];
|
||||
return ['data'=>Auth::user()->all_clients()->values()];
|
||||
}
|
||||
}
|
@@ -16,25 +16,25 @@ class UserHomeController extends Controller
|
||||
|
||||
public function invoice(Invoice $o)
|
||||
{
|
||||
return View('invoice',['o'=>$o]);
|
||||
return View('u.invoice',['o'=>$o]);
|
||||
}
|
||||
|
||||
public function invoice_pdf(Invoice $o)
|
||||
{
|
||||
return PDF::loadView('invoice', ['o'=>$o])->stream(sprintf('%s.pdf',$o->invoice_account_id));
|
||||
return PDF::loadView('u.invoice', ['o'=>$o])->stream(sprintf('%s.pdf',$o->invoice_account_id));
|
||||
}
|
||||
|
||||
public function home()
|
||||
{
|
||||
switch (Auth::user()->role()) {
|
||||
case 'customer':
|
||||
return View('userhome',['o'=>Auth::user()]);
|
||||
return View('u.home',['o'=>Auth::user()]);
|
||||
|
||||
case 'reseller':
|
||||
return View('resellerhome',['o'=>Auth::user()]);
|
||||
return View('r.home',['o'=>Auth::user()]);
|
||||
|
||||
case 'wholesaler':
|
||||
return View('resellerhome',['o'=>Auth::user()]);
|
||||
return View('r.home',['o'=>Auth::user()]);
|
||||
|
||||
default:
|
||||
abort(500,'Unknown role: '.Auth::user()->role());
|
||||
@@ -58,6 +58,6 @@ class UserHomeController extends Controller
|
||||
public function User(User $o)
|
||||
{
|
||||
// @todo Check authorised to see this account.
|
||||
return View('userhome',['o'=>$o]);
|
||||
return View('u.home',['o'=>$o]);
|
||||
}
|
||||
}
|
@@ -11,11 +11,15 @@ class Account extends Model
|
||||
|
||||
protected $appends = [
|
||||
'active_display',
|
||||
'services_count_html',
|
||||
'switch_url',
|
||||
];
|
||||
protected $visible = [
|
||||
'id',
|
||||
'company',
|
||||
'active_display',
|
||||
'services_count_html',
|
||||
'switch_url',
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -31,6 +35,11 @@ class Account extends Model
|
||||
return $this->belongsTo(Language::class);
|
||||
}
|
||||
|
||||
public function services()
|
||||
{
|
||||
return $this->hasMany(Service::class);
|
||||
}
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(\App\User::class);
|
||||
@@ -56,6 +65,16 @@ class Account extends Model
|
||||
return sprintf('<a href="/r/account/view/%s">%s</a>',$this->id,$this->account_id);
|
||||
}
|
||||
|
||||
public function getServicesCountHtmlAttribute()
|
||||
{
|
||||
return sprintf('%s <small>/%s</small>',$this->services->where('active',TRUE)->count(),$this->services->count());
|
||||
}
|
||||
|
||||
public function getSwitchUrlAttribute()
|
||||
{
|
||||
return sprintf('<a href="/a/switch/start/%s"><i class="fa fa-external-link"></i></a>',$this->user_id);
|
||||
}
|
||||
|
||||
private function _address()
|
||||
{
|
||||
$return = [];
|
||||
|
33
app/User.php
33
app/User.php
@@ -15,7 +15,7 @@ class User extends Authenticatable
|
||||
use HasApiTokens,Notifiable,UserSwitch;
|
||||
|
||||
protected $dates = ['created_at','updated_at','last_access'];
|
||||
protected $with = ['accounts'];
|
||||
protected $with = ['accounts.services'];
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
@@ -36,13 +36,20 @@ class User extends Authenticatable
|
||||
];
|
||||
|
||||
protected $appends = [
|
||||
'active_display',
|
||||
'services_count_html',
|
||||
'surfirstname',
|
||||
'switch_url',
|
||||
'user_id_url',
|
||||
];
|
||||
|
||||
protected $visible = [
|
||||
'active_display',
|
||||
'id',
|
||||
'surfirstname',
|
||||
'level',
|
||||
'services_count_html',
|
||||
'switch_url',
|
||||
'surfirstname',
|
||||
'user_id_url',
|
||||
];
|
||||
|
||||
@@ -88,6 +95,11 @@ class User extends Authenticatable
|
||||
return $this->hasMany(static::class,'parent_id','id');
|
||||
}
|
||||
|
||||
public function getActiveDisplayAttribute($value)
|
||||
{
|
||||
return sprintf('<span class="btn-sm btn-block btn-%s text-center">%s</span>',$this->active ? 'primary' : 'danger',$this->active ? 'Active' : 'Inactive');
|
||||
}
|
||||
|
||||
/**
|
||||
* Logged in users full name
|
||||
*
|
||||
@@ -130,7 +142,6 @@ class User extends Authenticatable
|
||||
{
|
||||
if (is_null($this->language_id))
|
||||
return config('SITE_SETUP')->language;
|
||||
dd(__METHOD__,$value,config('SITE_SETUP')->language);
|
||||
}
|
||||
|
||||
public function getPaymentHistoryAttribute()
|
||||
@@ -155,6 +166,16 @@ class User extends Authenticatable
|
||||
return $this->full_name;
|
||||
}
|
||||
|
||||
public function getServicesCountHtmlAttribute()
|
||||
{
|
||||
return sprintf('%s <small>/%s</small>',$this->services->where('active',TRUE)->count(),$this->services->count());
|
||||
}
|
||||
|
||||
public function getSwitchUrlAttribute()
|
||||
{
|
||||
return sprintf('<a href="/a/switch/start/%s"><i class="fa fa-external-link"></i></a>',$this->id);
|
||||
}
|
||||
|
||||
public function getUserIdAttribute()
|
||||
{
|
||||
return sprintf('%02s-%04s',$this->site_id,$this->id);
|
||||
@@ -235,15 +256,15 @@ class User extends Authenticatable
|
||||
public function role()
|
||||
{
|
||||
// If I have agents and no parent, I am the wholesaler
|
||||
if (is_null($this->parent_id) AND $this->all_agents()->count())
|
||||
if (is_null($this->parent_id) AND ($this->all_agents()->count() OR $this->all_clients()->count()))
|
||||
return 'wholesaler';
|
||||
|
||||
// If I have agents and a parent, I am a reseller
|
||||
elseif ($this->parent_id AND $this->all_agents()->count())
|
||||
elseif ($this->parent_id AND ($this->all_agents()->count() OR $this->all_clients()->count()))
|
||||
return 'reseller';
|
||||
|
||||
// If I have no agents and a parent, I am a customer
|
||||
elseif (! $this->all_agents()->count())
|
||||
elseif (! $this->all_agents()->count() AND ! $this->all_clients()->count())
|
||||
return 'customer';
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user