Files
einundzwanzig-app/app/Http/Resources/MeetupResource.php
T
HolgerHatGarKeineNode 9f8fda294a Implement leadership-based permissions for Meetup management
- 🔒 Restrict event creation, editing, and deletion to Meetup leaders (`is_leader`) and creators for consistency across APIs, frontend, and MCP.
-  Add new APIs for leader delegation: assign/remove Meetup leaders via `meetup_user.is_leader`.
- 🛠️ Replace loose member checks with specific leadership checks in policies, controllers, and views.
- 🧪 Add exhaustive tests to ensure only eligible leaders execute critical actions (e.g., event creation/edit, Meetup updates).
- 🔄 Refactor pivot relationships and models (`leadByMe`, `isLeader`) for explicit leadership handling.
-  Introduce artisan command `meetups:promote-existing-leaders` to transition legacy data.
2026-06-16 22:04:34 +02:00

47 lines
1.6 KiB
PHP

<?php
namespace App\Http\Resources;
use App\Models\Meetup;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
/**
* @mixin Meetup
*/
class MeetupResource extends JsonResource
{
/**
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return [
'id' => $this->id,
'name' => $this->name,
'slug' => $this->slug,
'city_id' => $this->city_id,
'intro' => $this->intro,
'telegram_link' => $this->telegram_link,
'webpage' => $this->webpage,
'twitter_username' => $this->twitter_username,
'matrix_group' => $this->matrix_group,
'nostr' => $this->nostr,
'simplex' => $this->simplex,
'signal' => $this->signal,
'community' => $this->community,
'visible_on_map' => $this->visible_on_map,
'is_active' => $this->is_active,
// Nur gesetzt, wenn die meetup_user-Pivot geladen ist (z. B. via
// /api/my-meetups). Sagt der App, ob der Token-Inhaber Leader dieses
// Meetups ist (darf bearbeiten + Leader verwalten).
'is_leader' => $this->whenPivotLoaded('meetup_user', fn (): bool => (bool) $this->pivot->is_leader),
'logo' => $this->getFirstMediaUrl('logo', 'thumb'),
'last_event_at' => $this->last_event_at,
'created_by' => $this->created_by,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
];
}
}