Initial invoice rendering

This commit is contained in:
Deon George
2018-08-01 17:09:38 +10:00
parent 1cde2a888a
commit c444e1d218
16 changed files with 500 additions and 28 deletions

View File

@@ -58,6 +58,11 @@ class User extends Authenticatable
return $this->hasMany(static::class,'parent_id','id')->with('clients');
}
public function language()
{
return $this->belongsTo(Models\Language::class);
}
public function invoices()
{
return $this->hasManyThrough(Models\Invoice::class,Models\Account::class);
@@ -120,6 +125,13 @@ class User extends Authenticatable
->filter();
}
public function getLanguageAttribute($value)
{
if (is_null($this->language_id))
return config('SITE_SETUP')->language;
dd(__METHOD__,$value,config('SITE_SETUP')->language);
}
public function getPaymentHistoryAttribute()
{
return $this->payments
@@ -152,6 +164,11 @@ class User extends Authenticatable
return sprintf('<a href="/u/account/view/%s">%s</a>',$this->id,$this->user_id);
}
public function isAdmin($id)
{
return $id AND in_array($this->role(),['wholesaler','reseller']) AND in_array($id,$this->all_accounts()->pluck('id')->toArray());
}
public function scopeActive()
{
return $this->where('active',TRUE);