Laravel 13 + Filament 5 admin panel and REST API for a non-profit developer collective, backed by the Pireon OAuth identity server. The public site is a separate, server-rendered application consuming /api/public/v1. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
53 lines
1.8 KiB
PHP
53 lines
1.8 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Http\Controllers\Api\PublicApi\V1;
|
|
|
|
use App\Http\Resources\PublicApi\PublicMemberResource;
|
|
use App\Models\Member;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
|
|
|
|
class MemberController extends PublicController
|
|
{
|
|
public function index(Request $request): AnonymousResourceCollection
|
|
{
|
|
$members = Member::query()
|
|
->with(['technologies', 'avatarMedia'])
|
|
->withCount('projects')
|
|
->public()
|
|
// Former members are kept but hidden by default; the frontend can
|
|
// ask for them to build an "alumni" section.
|
|
->unless($request->boolean('include_past'), fn (Builder $q) => $q->current())
|
|
->when($request->filled('technology'), fn (Builder $q) => $q
|
|
->whereHas('technologies', fn (Builder $t) => $t
|
|
->whereIn('slug', (array) $request->input('technology'))))
|
|
->orderByDesc('is_founder')
|
|
->orderBy('position')
|
|
->orderBy('name')
|
|
->paginate($this->perPage($request, 50))
|
|
->withQueryString();
|
|
|
|
return PublicMemberResource::collection($members);
|
|
}
|
|
|
|
public function show(string $slug): PublicMemberResource
|
|
{
|
|
$member = Member::query()
|
|
->with([
|
|
'technologies',
|
|
'avatarMedia',
|
|
'projects' => fn ($q) => $q->published()
|
|
->with(['technologies', 'coverMedia'])
|
|
->withCount(['calls as open_calls_count' => fn ($c) => $c->open()]),
|
|
])
|
|
->public()
|
|
->where('slug', $slug)
|
|
->firstOrFail();
|
|
|
|
return PublicMemberResource::make($member);
|
|
}
|
|
}
|