Compare commits
No commits in common. "23f57f684ea5135090b4646a32fc3a44444ab7f7" and "e106adc69e65b8e098129a08fdbaa27a0f9f0ad4" have entirely different histories.
23f57f684e
...
e106adc69e
@ -20,7 +20,13 @@ class AccountPolicy
|
||||
public function view(User $uo,Account $ao): bool
|
||||
{
|
||||
// If this is a service for an account managed by a user.
|
||||
return $uo->accounts_all->pluck('id')->contains($ao->id) || $uo->isWholesaler();
|
||||
return ($uo->accounts->pluck('id')->search($ao->id) !== FALSE)
|
||||
|
||||
// The user is the wholesaler
|
||||
OR $uo->isWholesaler()
|
||||
|
||||
// The user has this as one of their accounts
|
||||
OR $uo->accounts->pluck('id')->contains($ao->id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -19,7 +19,14 @@ class InvoicePolicy
|
||||
*/
|
||||
public function view(User $uo,Invoice $io): bool
|
||||
{
|
||||
return $uo->accounts_all->pluck('id')->contains($io->account_id) || $uo->isWholesaler();
|
||||
// If this is a service for an account managed by a user.
|
||||
return ($uo->invoices->pluck('id')->search($io->id) !== FALSE)
|
||||
|
||||
// The user is the wholesaler
|
||||
OR $uo->isWholesaler()
|
||||
|
||||
// The user has this as one of their accounts
|
||||
OR $uo->accounts->pluck('id')->contains($io->account_id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -20,7 +20,13 @@ class ServicePolicy
|
||||
public function view(User $uo, Service $so): bool
|
||||
{
|
||||
// If this is a service for an account managed by a user.
|
||||
return $uo->accounts_all->pluck('id')->contains($so->account_id) || $uo->isWholesaler();
|
||||
return ($uo->services->pluck('id')->search($so->id) !== FALSE)
|
||||
|
||||
// The user is the wholesaler
|
||||
OR $uo->isWholesaler()
|
||||
|
||||
// The user has this as one of their accounts
|
||||
OR $uo->accounts->pluck('id')->contains($so->account_id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -15,11 +15,11 @@ class UserPolicy
|
||||
*
|
||||
* @param User $uo
|
||||
* @param string $ability
|
||||
* @return null|bool
|
||||
* @return bool|null
|
||||
*/
|
||||
public function before(User $uo,string $ability): bool|NULL
|
||||
public function before(User $uo,string $ability): bool
|
||||
{
|
||||
return $uo->isWholesaler() ?: NULL;
|
||||
return $uo->isWholesaler() ?: FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -44,6 +44,9 @@ class UserPolicy
|
||||
public function view(User $uo,User $o): bool
|
||||
{
|
||||
// If this is a service for an account managed by a user.
|
||||
return ($uo->id == $o->id) || $uo->accounts_all->pluck('user_id')->contains($o->id) || $uo->isWholesaler();
|
||||
return ($uo->id == $o->id)
|
||||
|
||||
// The user has this as one of their accounts
|
||||
OR $uo->accounts->pluck('user')->pluck('id')->unique()->contains($o->id);
|
||||
}
|
||||
}
|
@ -4,7 +4,6 @@ namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
class Rtm extends Model
|
||||
{
|
||||
@ -24,20 +23,4 @@ class Rtm extends Model
|
||||
{
|
||||
return $this->hasMany(self::class,'parent_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all the children RTM records that this record is parent of
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function children_all(): Collection
|
||||
{
|
||||
$result = collect();
|
||||
$result->push($this->withoutRelations());
|
||||
|
||||
foreach ($this->children as $o)
|
||||
$result = $result->merge($o->children_all());
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
@ -317,18 +317,6 @@ class Service extends Model implements IDs
|
||||
return sprintf('%02s-%04s.%s',$this->site_id,$this->account_id,$this->getLIDattribute());
|
||||
}
|
||||
|
||||
/* STATIC */
|
||||
|
||||
public static function movements(User $uo): Collection
|
||||
{
|
||||
return (new self)
|
||||
->active()
|
||||
->serviceUserAuthorised($uo)
|
||||
->where('order_status','!=','ACTIVE')
|
||||
->with(['account','product'])
|
||||
->get();
|
||||
}
|
||||
|
||||
/* RELATIONS */
|
||||
|
||||
/**
|
||||
|
@ -7,12 +7,17 @@ use Illuminate\Notifications\Notifiable;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Database\Eloquent\Collection as DatabaseCollection;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Laravel\Passport\HasApiTokens;
|
||||
use Leenooks\Traits\ScopeActive;
|
||||
use Leenooks\Traits\UserSwitch;
|
||||
|
||||
use App\Interfaces\IDs;
|
||||
use App\Models\Scopes\SiteScope;
|
||||
use App\Notifications\ResetPassword as ResetPasswordNotification;
|
||||
use App\Traits\SiteID;
|
||||
|
||||
/**
|
||||
* Class User
|
||||
@ -22,12 +27,14 @@ use App\Notifications\ResetPassword as ResetPasswordNotification;
|
||||
*/
|
||||
class User extends Authenticatable implements IDs
|
||||
{
|
||||
use HasFactory,HasApiTokens,Notifiable,UserSwitch,ScopeActive;
|
||||
use HasFactory,HasApiTokens,Notifiable,UserSwitch,SiteID,ScopeActive;
|
||||
|
||||
private const CACHE_TIME = 3600;
|
||||
|
||||
protected $casts = [
|
||||
'last_access' => 'datetime:Y-m-d H:i:s',
|
||||
protected $dates = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'last_access'
|
||||
];
|
||||
|
||||
/**
|
||||
@ -89,25 +96,27 @@ class User extends Authenticatable implements IDs
|
||||
/* RELATIONS */
|
||||
|
||||
/**
|
||||
* This user's accounts
|
||||
* The accounts that this user manages
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
* @note This cannot be loaded with "with"?
|
||||
*/
|
||||
public function accounts()
|
||||
{
|
||||
return $this->hasMany(Account::class)
|
||||
->orWhereIn('id',$this->rtm_accounts()->pluck('id'))
|
||||
->active();
|
||||
}
|
||||
|
||||
/**
|
||||
* The accounts that this user manages
|
||||
* This users invoices
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
* @note This cannot be preloaded with load() or with() - $this is a blank object
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasManyThrough
|
||||
* @deprecated Accounts have invoices, not users
|
||||
*/
|
||||
public function accounts_all()
|
||||
public function invoices()
|
||||
{
|
||||
return $this->hasMany(Account::class)
|
||||
->when((! is_null($this->rtm) && $this->id),
|
||||
fn($query)=>$query->orWhereIn('rtm_id',$this->rtm?->children_all()->pluck('id')))
|
||||
return $this->hasManyThrough(Invoice::class,Account::class)
|
||||
->active();
|
||||
}
|
||||
|
||||
@ -123,20 +132,37 @@ class User extends Authenticatable implements IDs
|
||||
|
||||
/**
|
||||
* Return the routes to market account for this user
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasOneThrough
|
||||
*/
|
||||
public function rtm()
|
||||
{
|
||||
return $this->hasOneThrough(Rtm::class,Account::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* The services this user has
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasManyThrough
|
||||
* @deprecated Accounts have services, not users
|
||||
*/
|
||||
public function services()
|
||||
{
|
||||
return $this->hasManyThrough(Service::class,Account::class)
|
||||
->with(['product.type'])
|
||||
->active();
|
||||
}
|
||||
|
||||
/**
|
||||
* Supplier configuration for this user
|
||||
*
|
||||
* @deprecated To move to account->suppliers()
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
* @deprecated Move to account->suppliers()
|
||||
*/
|
||||
public function suppliers()
|
||||
{
|
||||
return $this->belongsToMany(Supplier::class)
|
||||
->where('supplier_user.site_id',$this->site_id)
|
||||
->withPivot('id','created_at');
|
||||
}
|
||||
|
||||
@ -153,7 +179,7 @@ class User extends Authenticatable implements IDs
|
||||
}
|
||||
|
||||
/**
|
||||
* Logged in user's full name
|
||||
* Logged in users full name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@ -163,8 +189,24 @@ class User extends Authenticatable implements IDs
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a friendly string of this persons role
|
||||
* Return my accounts, but only those accounts with the same group_id
|
||||
*
|
||||
* @note Users can only manage accounts with the same group ID, thereby ensuring they dont see different
|
||||
* pricing options - since prices can be controlled by groups
|
||||
* @return Collection
|
||||
*/
|
||||
public function getMyAccountsAttribute(): Collection
|
||||
{
|
||||
$result = $this->accounts->where('user_id',$this->id);
|
||||
|
||||
if (! $result->count())
|
||||
return $result;
|
||||
|
||||
return $this->isReseller() ? $result : $result->groupBy('group.id')->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a friendly string of this persons role
|
||||
* @return string
|
||||
*/
|
||||
public function getRoleAttribute(): string
|
||||
@ -217,6 +259,22 @@ class User extends Authenticatable implements IDs
|
||||
|
||||
/* METHODS */
|
||||
|
||||
/**
|
||||
* Show this user's clients with service movements
|
||||
*
|
||||
* A service movement, is an active service where the status is not ACTIVE
|
||||
*
|
||||
* @return DatabaseCollection
|
||||
*/
|
||||
public function client_service_movements(): DatabaseCollection
|
||||
{
|
||||
return Service::active()
|
||||
->serviceUserAuthorised($this)
|
||||
->where('order_status','!=','ACTIVE')
|
||||
->with(['account','product'])
|
||||
->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the user is an admin of the user with $id
|
||||
*
|
||||
@ -225,11 +283,7 @@ class User extends Authenticatable implements IDs
|
||||
*/
|
||||
public function isAdmin(User $user=NULL): bool
|
||||
{
|
||||
return $user->exists
|
||||
&& $this->isReseller()
|
||||
&& $this->accounts_all
|
||||
->pluck('user_id')
|
||||
->contains($user->id);
|
||||
return $user->exists AND $this->isReseller() AND $this->accounts->pluck('user_id')->contains($user->id);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -257,11 +311,9 @@ class User extends Authenticatable implements IDs
|
||||
*
|
||||
* @param bool $future
|
||||
* @return DatabaseCollection
|
||||
* @deprecated This should be done in accounts
|
||||
*/
|
||||
public function next_invoice_items(bool $future=FALSE): Collection
|
||||
public function next_invoice_items(bool $future=FALSE): DatabaseCollection
|
||||
{
|
||||
return collect();
|
||||
$result = new DatabaseCollection;
|
||||
$this->services->load(['invoice_items.taxes']);
|
||||
|
||||
@ -287,6 +339,117 @@ class User extends Authenticatable implements IDs
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an SQL query that will return a list of invoices
|
||||
*
|
||||
* @return \Illuminate\Database\Query\Builder
|
||||
*/
|
||||
private function query_invoice_items()
|
||||
{
|
||||
return DB::table('invoice_items')
|
||||
->select([
|
||||
'invoice_id',
|
||||
DB::raw('invoice_items.id AS invoice_item_id'),
|
||||
DB::raw('COALESCE(invoice_items.discount_amt,0) AS discount'),
|
||||
DB::raw('quantity*price_base AS base'),
|
||||
DB::raw('invoice_item_taxes.amount AS tax'),
|
||||
])
|
||||
->leftjoin('invoice_item_taxes',['invoice_item_taxes.invoice_item_id'=>'invoice_items.id'])
|
||||
->where('invoice_items.active',TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an SQL query that will return payment summaries by invoices.
|
||||
*
|
||||
* @return \Illuminate\Database\Query\Builder
|
||||
*/
|
||||
private function query_payment_items()
|
||||
{
|
||||
return DB::table('payment_items')
|
||||
->select([
|
||||
'payment_id',
|
||||
'invoice_id',
|
||||
DB::raw('SUM(amount) AS allocate'),
|
||||
])
|
||||
->where('amount','>',0)
|
||||
->groupBy(['invoice_id','payment_id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an SQL query that will summarise invoices with payments
|
||||
*
|
||||
* @return \Illuminate\Database\Query\Builder
|
||||
* @todo change this to just return outstanding invoices as a collection.
|
||||
* @deprecated Use account->invoiceSummary
|
||||
*/
|
||||
public function query_invoice_summary()
|
||||
{
|
||||
$invoices = (new Invoice)
|
||||
->select([
|
||||
'invoice_id',
|
||||
DB::raw('SUM(discount) AS discount'),
|
||||
DB::raw('SUM(base) AS base'),
|
||||
DB::raw('SUM(tax) AS tax'),
|
||||
DB::raw('base+tax-discount AS total'),
|
||||
DB::raw('0 AS payments'),
|
||||
DB::raw('0 AS payment_fees'),
|
||||
])
|
||||
->from($this->query_invoice_items(),'II')
|
||||
->join('invoices',['invoices.id'=>'II.invoice_id'])
|
||||
->whereIN('account_id',$this->accounts->pluck('id'))
|
||||
->where('invoices.active',TRUE)
|
||||
->groupBy(['invoice_id','base','tax','discount']);
|
||||
|
||||
$payments = (new Payment)
|
||||
->select([
|
||||
'invoice_id',
|
||||
DB::raw('0 AS discount'),
|
||||
DB::raw('0 AS base'),
|
||||
DB::raw('0 AS tax'),
|
||||
DB::raw('0 AS total'),
|
||||
DB::raw('SUM(allocate) AS payments'),
|
||||
DB::raw('SUM(fees_amt) AS payment_fees'),
|
||||
])
|
||||
->from($this->query_payment_items(),'PI')
|
||||
->join('payments',['payments.id'=>'PI.payment_id'])
|
||||
->whereIN('account_id',$this->accounts->pluck('id'))
|
||||
//->where('payments.active',TRUE) // @todo To implement
|
||||
->groupBy(['invoice_id']);
|
||||
|
||||
$summary = (new Invoice)
|
||||
->withoutGlobalScope(SiteScope::class)
|
||||
->select([
|
||||
'invoice_id',
|
||||
DB::raw('SUM(discount) AS discount'),
|
||||
DB::raw('SUM(base) AS invoice_base'),
|
||||
DB::raw('SUM(tax) AS invoice_tax'),
|
||||
DB::raw('SUM(total) AS invoice_total'),
|
||||
DB::raw('SUM(payments) AS payments'),
|
||||
DB::raw('SUM(payment_fees) AS payment_fees'),
|
||||
])
|
||||
->from($invoices->unionAll($payments),'invoices')
|
||||
->groupBy(['invoice_id']);
|
||||
|
||||
return (new Invoice)
|
||||
->select([
|
||||
'account_id',
|
||||
'id',
|
||||
'due_at',
|
||||
'created_at',
|
||||
'discount',
|
||||
'invoice_base',
|
||||
'invoice_tax',
|
||||
'invoice_total',
|
||||
'payments',
|
||||
'payment_fees',
|
||||
DB::raw('invoice_total-payments AS balance'),
|
||||
])
|
||||
->join('invoices',['invoices.id'=>'invoice_id'])
|
||||
->with(['items.taxes'])
|
||||
->from($summary,'summary')
|
||||
->groupBy(['id','account_id','discount','invoice_base','invoice_tax','invoice_total','payments','payment_fees']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine what the logged in user's role is
|
||||
* + Wholesaler - aka Super User
|
||||
@ -297,8 +460,67 @@ class User extends Authenticatable implements IDs
|
||||
*/
|
||||
public function role()
|
||||
{
|
||||
return $this->rtm
|
||||
? ($this->rtm->parent_id ? 'reseller' : 'wholesaler')
|
||||
: 'customer';
|
||||
// Cache our role for this session
|
||||
$cache_key = sprintf('%s:%s:%s',$this->id,__METHOD__,Session::getId());
|
||||
|
||||
return Cache::remember($cache_key,self::CACHE_TIME,function() {
|
||||
// Get the RTM for our accounts
|
||||
$rtms = Rtm::whereIn('account_id',$this->accounts->pluck('id'))->get();
|
||||
|
||||
// If I have no parent, I am the wholesaler
|
||||
if ($rtms->whereNull('parent_id')->count())
|
||||
return 'wholesaler';
|
||||
|
||||
// If I exist in the RTM table, I'm a reseller
|
||||
else if ($rtms->count())
|
||||
return 'reseller';
|
||||
|
||||
// Otherwise a client
|
||||
else
|
||||
return 'customer';
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the accounts that this user can manage
|
||||
* This method is a helper to User::accounts() - use $user->accounts instead
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
private function rtm_accounts(): Collection
|
||||
{
|
||||
return Account::whereIn('rtm_id',$this->rtm_list()->pluck('id'))
|
||||
->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the RTM hierarchy that this user can manage
|
||||
*
|
||||
* @param Rtm|null $rtm
|
||||
* @return Collection
|
||||
*/
|
||||
public function rtm_list(Rtm $rtm=NULL): Collection
|
||||
{
|
||||
// If this user doesnt manage any accounts
|
||||
if (! $this->exists || ! $this->rtm)
|
||||
return collect();
|
||||
|
||||
$list = collect();
|
||||
|
||||
// Add this RTM to the list
|
||||
if (! $rtm) {
|
||||
$list->push($this->rtm);
|
||||
$children = $this->rtm->children;
|
||||
|
||||
} else {
|
||||
$list->push($rtm);
|
||||
$children =$rtm->children;
|
||||
}
|
||||
|
||||
// Capture any children
|
||||
foreach ($children as $child)
|
||||
$list->push($this->rtm_list($child));
|
||||
|
||||
return $rtm ? $list : $list->flatten()->unique(function($item) { return $item->id; });
|
||||
}
|
||||
}
|
@ -16,6 +16,6 @@ trait ScopeServiceUserAuthorised
|
||||
public function scopeServiceUserAuthorised($query,User $uo)
|
||||
{
|
||||
return $query
|
||||
->whereIN('services.account_id',$uo->accounts_all->pluck('id'));
|
||||
->whereIN('services.account_id',$uo->accounts->pluck('id'));
|
||||
}
|
||||
}
|
@ -1,25 +1,27 @@
|
||||
@if($user->isReseller() && ($o->accounts->count() <= 2) && ($x=$o->accounts->pluck('providers')->flatten())->count())
|
||||
@if(Auth::user()->isReseller() && $o->my_accounts->count() <= 2 && $o->my_accounts->pluck('providers')->flatten()->count())
|
||||
<div class="col-12 col-sm-4 col-md-2">
|
||||
<div class="info-box">
|
||||
<span class="info-box-icon bg-dark elevation-1"><i class="fas fa-file-invoice"></i></span>
|
||||
<div class="info-box-content">
|
||||
<span class="info-box-text">Accounting</span>
|
||||
@foreach($x as $po)
|
||||
<span class="info-box-number"><a href="{{ url(($po->api_class())::url().'/customerdetail?nameId='.$po->pivot->ref) }}" target="{{ $po->name }}">{{ ucfirst($po->name) }}</a></span>
|
||||
@foreach ($o->my_accounts as $ao)
|
||||
@foreach($ao->providers as $po)
|
||||
<span class="info-box-number"><a href="{{ url(($po->api_class())::url().'/customerdetail?nameId='.$po->pivot->ref) }}" target="{{ $po->name }}">{{ ucfirst($po->name) }}</a></span>
|
||||
@endforeach
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@if ($o->accounts_all->count() > 1)
|
||||
@if ($o->accounts->count() > 1)
|
||||
<div class="col-12 col-sm-4 col-md-2">
|
||||
<div class="info-box">
|
||||
<span class="info-box-icon bg-primary elevation-1"><i class="fas fa-user"></i></span>
|
||||
|
||||
<div class="info-box-content">
|
||||
<span class="info-box-text">Linked Accounts</span>
|
||||
<span class="info-box-number">{{ number_format($o->accounts_all->count()) }}</span>
|
||||
<span class="info-box-number">{{ number_format($o->my_accounts->count()) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -31,7 +33,8 @@
|
||||
|
||||
<div class="info-box-content">
|
||||
<span class="info-box-text">Active Services</span>
|
||||
<span class="info-box-number">{{ $o->accounts_all->map(fn($item)=>$item->services->where('active',TRUE)->count())->sum() }} <small>/{{ $o->accounts_all->map(fn($item)=>$item->services->count())->sum() }}</small></span>
|
||||
<!-- @todo This should count of inactive services too -->
|
||||
<span class="info-box-number">{{ $o->services->count() }} <small>/{{ $o->services->count() }}</small></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -42,7 +45,7 @@
|
||||
|
||||
<div class="info-box-content">
|
||||
<span class="info-box-text">Account Balance</span>
|
||||
<span class="info-box-number"><small>$</small> {{ number_format(($x=$o->accounts_all->map(fn($item)=>$item->invoiceSummaryDue()->get()->pluck('_balance'))->flatten())->sum(),2) }}</span>
|
||||
<span class="info-box-number"><small>$</small> {{ number_format(($x=$o->accounts->map(fn($item)=>$item->invoiceSummaryDue()->get()->pluck('_balance'))->flatten())->sum(),2) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -24,7 +24,7 @@
|
||||
<div class="card-header p-0 pt-1">
|
||||
<ul class="nav nav-tabs" id="accounts-tab" role="tablist">
|
||||
<li class="pt-2 px-3"><h3 class="card-title">Accounts</h3></li>
|
||||
@foreach($o->accounts as $ao)
|
||||
@foreach($o->my_accounts as $ao)
|
||||
<li class="nav-item">
|
||||
<a class="nav-link @if(! $loop->index)active @endif" href="#account_{{ $ao->id }}" data-toggle="tab" aria-controls="account_{{ $ao->id }}" aria-selected="true">{{ $ao->name }}</a>
|
||||
</li>
|
||||
@ -42,7 +42,7 @@
|
||||
|
||||
<div class="card-body">
|
||||
<div class="tab-content" id="accounts-tab-content">
|
||||
@foreach($o->accounts as $ao)
|
||||
@foreach($o->my_accounts as $ao)
|
||||
<div class="tab-pane fade @if(! $loop->index)show active @endif" id="account_{{ $ao->id }}" role="tabpanel" aria-labelledby="account_{{ $ao->id }}">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
@ -93,7 +93,7 @@
|
||||
</div>
|
||||
@endforeach
|
||||
|
||||
@if($o==$user)
|
||||
@if ($o == $user)
|
||||
@canany('reseller','wholesaler')
|
||||
<div class="tab-pane" id="tab-reseller" role="tabpanel">
|
||||
@include('theme.backend.adminlte.r.home.widget.home')
|
||||
|
@ -4,7 +4,7 @@
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
@if ($x=$user->accounts_all->count())
|
||||
@if ($user->accounts->count())
|
||||
<table class="table table-striped table-hover" id="accounts">
|
||||
<thead>
|
||||
<tr>
|
||||
@ -14,7 +14,7 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($user->accounts_all as $ao)
|
||||
@foreach ($user->accounts as $ao)
|
||||
<tr>
|
||||
<td><a href="{{ url('r/switch/start',$ao->user_id) }}"><i class="fas fa-external-link-alt"></i></a></td>
|
||||
<td>{{ $ao->name }}</td>
|
||||
@ -25,7 +25,7 @@
|
||||
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th>Count {{ $x }}</th>
|
||||
<th>Count {{ $user->accounts->count() }}</th>
|
||||
<th colspan="2"> </th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
|
@ -1,7 +1,3 @@
|
||||
@php
|
||||
use App\Models\Service;
|
||||
@endphp
|
||||
|
||||
<!-- Show client movements -->
|
||||
<div class="card card-dark">
|
||||
<div class="card-header">
|
||||
@ -9,7 +5,7 @@ use App\Models\Service;
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
@if (($x=Service::movements($user))->count())
|
||||
@if (($x=$user->client_service_movements())->count())
|
||||
<table class="table table-striped table-hover" id="service_movements">
|
||||
<thead>
|
||||
<tr>
|
||||
@ -58,7 +54,6 @@ use App\Models\Service;
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@section('page-styles')
|
||||
@css(datatables,bootstrap4|rowgroup)
|
||||
@append
|
||||
|
Loading…
Reference in New Issue
Block a user