1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-05 18:52:44 +01:00

Filter scope to company

This commit is contained in:
David Bomba 2019-03-28 21:16:41 +11:00
parent fd8c19d911
commit d2e5563dbe
2 changed files with 7 additions and 6 deletions

View File

@ -167,12 +167,11 @@ class ClientFilters extends QueryFilters
return $query;
}
public function company()
{
$entity = strtolower(class_basename(Client::class));
public function entityFilter()
{
return $this->builder->whereCompanyId(auth()->user()->company()->id);
$this->builder->where($entity .'.company_id', '=', auth()->user()->company()->id);
}
}
}

View File

@ -61,6 +61,8 @@ abstract class QueryFilters
{
$this->builder = $builder;
$this->entityFilter();
foreach ($this->filters() as $name => $value) {
if (! method_exists($this, $name)) {
continue;