|
@@ -2,6 +2,7 @@
|
|
|
|
|
|
namespace App\Http\Requests;
|
|
namespace App\Http\Requests;
|
|
|
|
|
|
|
|
+use App\Models\Company;
|
|
use App\Models\User;
|
|
use App\Models\User;
|
|
use Illuminate\Database\Query\Builder;
|
|
use Illuminate\Database\Query\Builder;
|
|
use Illuminate\Support\Facades\Auth;
|
|
use Illuminate\Support\Facades\Auth;
|
|
@@ -10,7 +11,8 @@ trait RuleHelper
|
|
{
|
|
{
|
|
protected function userCompanyWhere(): \Closure
|
|
protected function userCompanyWhere(): \Closure
|
|
{
|
|
{
|
|
- return fn (Builder $query) => $query->where('company_id', Auth::user()->company_id);
|
|
|
|
|
|
+ $company = Company::query()->where("company_id", Auth::user()->company_id)->orWhere('parent_id', Auth::user()->company_id)->pluck("id");
|
|
|
|
+ return fn (Builder $query) => $query->whereIn('company_id', $company->pluck("id")->toArray());
|
|
}
|
|
}
|
|
|
|
|
|
protected function usersCompanyRules(): array
|
|
protected function usersCompanyRules(): array
|