mirror of
https://github.com/AnimeThemes/animethemes-server.git
synced 2026-09-03 11:15:04 +02:00
28 lines
704 B
PHP
28 lines
704 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\GraphQL\Builders\List;
|
|
|
|
use App\Enums\Models\List\ExternalProfileVisibility;
|
|
use App\Models\List\ExternalProfile;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
class ExternalProfilePaginationBuilder
|
|
{
|
|
/**
|
|
* @param array<string, mixed> $args
|
|
*/
|
|
public function __invoke(Builder $builder, null $_, null $root, $args): Builder
|
|
{
|
|
$builder->where(ExternalProfile::ATTRIBUTE_VISIBILITY, ExternalProfileVisibility::PUBLIC->value);
|
|
|
|
if ($user = Auth::user()) {
|
|
return $builder->orWhereBelongsTo($user, ExternalProfile::RELATION_USER);
|
|
}
|
|
|
|
return $builder;
|
|
}
|
|
}
|