1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00

Adjustments for mini_load

This commit is contained in:
David Bomba 2023-08-06 15:24:13 +10:00
parent ada3c78556
commit 742d566f27
2 changed files with 5 additions and 31 deletions

View File

@ -516,19 +516,11 @@ class BaseController extends Controller
$query->where('bank_transactions.user_id', $user->id);
}
},
'company.bank_transaction_rules'=> function ($query) use ($updated_at, $user) {
$query->where('updated_at', '>=', $updated_at);
if (! $user->isAdmin() && !$user->hasIntersectPermissions(['create_bank_transaction','edit_bank_transaction','view_bank_transaction'])) {
$query->where('bank_transaction_rules.user_id', $user->id);
}
'company.bank_transaction_rules'=> function ($query) {
$query->whereNotNull('updated_at');
},
'company.task_schedulers'=> function ($query) use ($updated_at, $user) {
$query->where('updated_at', '>=', $updated_at);
if (! $user->isAdmin()) {
$query->where('schedulers.user_id', $user->id);
}
'company.task_schedulers'=> function ($query) {
$query->whereNotNull('updated_at');
},
]
);
@ -656,24 +648,6 @@ class BaseController extends Controller
return $this->response($this->manager->createData($resource)->toArray());
}
/**
* In case a user is not an admin and is
* able to access multiple companies, then we
* need to pass back the mini load only
*
* @deprecated
* @return bool
*/
// private function complexPermissionsUser(): bool
// {
// //if the user is attached to more than one company AND they are not an admin across all companies
// if (auth()->user()->company_users()->count() > 1 && (auth()->user()->company_users()->where('is_admin', 1)->count() != auth()->user()->company_users()->count())) {
// return true;
// }
// return false;
// }
/**
* Passes back the miniloaded data response
*

View File

@ -34,7 +34,7 @@ use Illuminate\Database\Eloquent\ModelNotFoundException as ModelNotFoundExceptio
* @property int $company_id
* @property int $id
* @property int $user_id
* @property int @assigned_user_id
* @property int $assigned_user_id
* @property \App\Models\Company $company
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel|Illuminate\Database\Eloquent\Relations\BelongsTo|\Awobaz\Compoships\Database\Eloquent\Relations\BelongsTo|\App\Models\Company company()
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel|Illuminate\Database\Eloquent\Relations\HasMany|BaseModel orderBy()