diff --git a/app/Jobs/AccountingAccountSync.php b/app/Jobs/AccountingAccountSync.php index 388844a..e984306 100644 --- a/app/Jobs/AccountingAccountSync.php +++ b/app/Jobs/AccountingAccountSync.php @@ -40,7 +40,7 @@ class AccountingAccountSync implements ShouldQueue public function handle() { $api = $this->to->provider->API($this->to); - $accounts = Account::get(); + $accounts = Account::with(['user'])->get(); foreach ($api->getCustomers() as $customer) { $ao = NULL; @@ -54,7 +54,7 @@ class AccountingAccountSync implements ShouldQueue $ao = $x->pop(); // Look based on Name - } elseif (($x=$accounts->filter(function($item) use ($customer) { return $item->company == $customer->companyname || $item->name == $customer->fullname; }))->count() === 1) { + } elseif (($x=$accounts->filter(function($item) use ($customer) { return $item->company == $customer->companyname || $item->name == $customer->fullname || $item->user->email == $customer->email; }))->count() === 1) { $ao = $x->pop(); } else { diff --git a/app/Models/Account.php b/app/Models/Account.php index c62631d..69c1ff5 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -45,13 +45,6 @@ class Account extends Model implements IDs return $this->hasMany(Charge::class); } - public function providers() - { - return $this->belongsToMany(ProviderOauth::class,'account_provider') - ->where('account_provider.site_id',$this->site_id) - ->withPivot('ref','synctoken','created_at','updated_at'); - } - /** * Return the country the user belongs to */ @@ -85,6 +78,13 @@ class Account extends Model implements IDs return $this->hasMany(Payment::class); } + public function providers() + { + return $this->belongsToMany(ProviderOauth::class,'account_provider') + ->where('account_provider.site_id',$this->site_id) + ->withPivot('ref','synctoken','created_at','updated_at'); + } + public function services($active=FALSE) { $query = $this->hasMany(Service::class); diff --git a/resources/views/theme/backend/adminlte/common/account/widget/summary.blade.php b/resources/views/theme/backend/adminlte/common/account/widget/summary.blade.php index 6dd44f7..3a706ad 100644 --- a/resources/views/theme/backend/adminlte/common/account/widget/summary.blade.php +++ b/resources/views/theme/backend/adminlte/common/account/widget/summary.blade.php @@ -1,5 +1,21 @@ +@if($o->my_accounts->count() <= 2 && $o->my_accounts->pluck('providers')->flatten()->count()) +