mirror of
https://github.com/AnimeThemes/animethemes-server.git
synced 2026-07-11 01:24:46 +02:00
40 lines
1.1 KiB
PHP
40 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\GraphQL\Controllers\List;
|
|
|
|
use App\Enums\Models\List\ExternalProfileVisibility;
|
|
use App\GraphQL\Controllers\BaseController;
|
|
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;
|
|
|
|
/**
|
|
* @extends BaseController<ExternalProfile>
|
|
*/
|
|
class ExternalProfileController extends BaseController
|
|
{
|
|
final public const ROUTE_SLUG = 'id';
|
|
|
|
/**
|
|
* Apply the query builder to the index query.
|
|
*
|
|
* @param Builder<ExternalProfile> $builder
|
|
* @param array $args
|
|
* @return Builder<ExternalProfile>
|
|
*/
|
|
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;
|
|
}
|
|
}
|