mirror of
https://github.com/AnimeThemes/animethemes-server.git
synced 2026-07-11 01:24:46 +02:00
41 lines
1.1 KiB
PHP
41 lines
1.1 KiB
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;
|
|
use Nuwave\Lighthouse\Execution\ResolveInfo;
|
|
use Nuwave\Lighthouse\Support\Contracts\GraphQLContext;
|
|
|
|
/**
|
|
* Class ExternalProfileBuilder.
|
|
*/
|
|
class ExternalProfileBuilder
|
|
{
|
|
/**
|
|
* Apply the query builder to the index query.
|
|
*
|
|
* @param Builder $builder
|
|
* @param mixed $value
|
|
* @param mixed $root
|
|
* @param array $args
|
|
* @param GraphQLContext $context
|
|
* @param ResolveInfo $resolveInfo
|
|
* @return Builder
|
|
*/
|
|
public function index(Builder $builder, mixed $value, mixed $root, array $args, GraphQLContext $context, ResolveInfo $resolveInfo): Builder
|
|
{
|
|
$builder->where(ExternalProfile::ATTRIBUTE_VISIBILITY, ExternalProfileVisibility::PUBLIC->value);
|
|
|
|
if ($user = Auth::user()) {
|
|
return $builder->orWhereBelongsTo($user, ExternalProfile::RELATION_USER);
|
|
}
|
|
|
|
return $builder;
|
|
}
|
|
}
|