*/ public function for(User $user): Builder { if (! $user->isStaff()) { return File::query()->visibleToClient($user); } // Mirrors FilePolicy::view()'s staff branch: the permission half is // a property of the viewer, not the row, so it either opens the // whole scope or closes it entirely. $permitted = $user->can('upload') || $user->can('edit_files') || $user->can('edit_others_files'); if (! $permitted) { return File::query()->whereRaw('1 = 0'); } return $this->scope->files($user); } }