mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-08 00:02:15 +01:00
move Client visibleByEmployee logic from controller to model
This commit is contained in:
@@ -12,7 +12,6 @@ use App\Http\Resources\V1\Client\ClientCollection;
|
||||
use App\Http\Resources\V1\Client\ClientResource;
|
||||
use App\Models\Client;
|
||||
use App\Models\Organization;
|
||||
use App\Models\Project;
|
||||
use Illuminate\Auth\Access\AuthorizationException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Support\Carbon;
|
||||
@@ -47,13 +46,7 @@ class ClientController extends Controller
|
||||
->orderBy('created_at', 'desc');
|
||||
|
||||
if (! $canViewAllClients) {
|
||||
$projectsQuery = Project::query()
|
||||
->whereBelongsTo($organization, 'organization')
|
||||
->visibleByEmployee($user)
|
||||
->distinct()
|
||||
->select('client_id');
|
||||
|
||||
$clientsQuery->whereIn('id', $projectsQuery);
|
||||
$clientsQuery->visibleByEmployee($user);
|
||||
}
|
||||
|
||||
$filterArchived = $request->getFilterArchived();
|
||||
|
||||
Reference in New Issue
Block a user