Work in progress, initial dashboard
This commit is contained in:
38
app/User.php
38
app/User.php
@@ -2,15 +2,17 @@
|
||||
|
||||
namespace App;
|
||||
|
||||
use Laravel\Passport\HasApiTokens;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
protected $table = 'ab_account';
|
||||
private $_currency;
|
||||
// @todo We cannot use timestamps - we should create the normal timestamps columns under laravel.
|
||||
public $timestamps = FALSE;
|
||||
|
||||
use Notifiable;
|
||||
use HasApiTokens, Notifiable;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
@@ -43,17 +45,17 @@ class User extends Authenticatable
|
||||
*/
|
||||
public function invoices()
|
||||
{
|
||||
return $this->hasMany(Models\Invoice::class,'account_id');
|
||||
return $this->hasMany(Models\Invoice::class,'account_id');
|
||||
}
|
||||
|
||||
public function language()
|
||||
{
|
||||
return $this->belongsTo(Models\Language::class);
|
||||
return $this->belongsTo(Models\Language::class);
|
||||
}
|
||||
|
||||
public function payments()
|
||||
{
|
||||
return $this->hasMany(Models\Payment::class,'account_id');
|
||||
return $this->hasMany(Models\Payment::class,'account_id');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,7 +63,7 @@ class User extends Authenticatable
|
||||
*/
|
||||
public function services()
|
||||
{
|
||||
return $this->hasMany(Models\Service::class,'account_id');
|
||||
return $this->hasMany(Models\Service::class,'account_id');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -82,28 +84,30 @@ class User extends Authenticatable
|
||||
|
||||
public function getInvoicesDueAttribute()
|
||||
{
|
||||
return $this->invoices
|
||||
->where('active',TRUE)
|
||||
->sortBy('id')
|
||||
->transform(function ($item) { if ($item->due) return $item; })
|
||||
->reverse()
|
||||
->filter();
|
||||
return $this->invoices
|
||||
->where('active',TRUE)
|
||||
->sortBy('id')
|
||||
->transform(function ($item) { if ($item->due) return $item; })
|
||||
->reverse()
|
||||
->filter();
|
||||
}
|
||||
|
||||
public function getPaymentHistoryAttribute()
|
||||
{
|
||||
return $this->payments
|
||||
->sortBy('date_payment')
|
||||
->reverse();
|
||||
return $this->payments
|
||||
->sortBy('date_payment')
|
||||
->reverse();
|
||||
}
|
||||
|
||||
public function getNameAttribute()
|
||||
{
|
||||
return $this->full_name;
|
||||
return $this->full_name;
|
||||
}
|
||||
|
||||
public function getServicesActiveAttribute()
|
||||
{
|
||||
return $this->services->where('active',TRUE);
|
||||
return $this
|
||||
->services
|
||||
->where('active',TRUE);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user