Initial invoice rendering
This commit is contained in:
17
app/User.php
17
app/User.php
@@ -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);
|
||||
|
Reference in New Issue
Block a user