mirror of
https://github.com/HolgerHatGarKeineNode/einundzwanzig-app.git
synced 2026-06-17 16:40:31 +00:00
9f8fda294a
- 🔒 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.
54 lines
1.7 KiB
PHP
54 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Api;
|
|
|
|
use App\Enums\RecurrenceType;
|
|
use App\Models\Meetup;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
class StoreMeetupEventRequest extends FormRequest
|
|
{
|
|
/**
|
|
* Termine darf nur anlegen, wer das zugehörige Meetup bearbeiten darf
|
|
* (Ersteller/Leader/Super-Admin) — dieselbe Berechtigung wie die
|
|
* Stammdaten. Existenz/Pflicht von meetup_id prüft rules() (422); ist ein
|
|
* gültiges Meetup angegeben, muss der Nutzer dafür berechtigt sein.
|
|
*/
|
|
public function authorize(): bool
|
|
{
|
|
$meetup = Meetup::find($this->input('meetup_id'));
|
|
|
|
return $meetup === null || $this->user()->can('update', $meetup);
|
|
}
|
|
|
|
/**
|
|
* @return array<string, array<int, mixed>>
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'meetup_id' => ['required', 'integer', 'exists:meetups,id'],
|
|
'start' => ['required', 'date'],
|
|
'location' => ['nullable', 'string', 'max:255'],
|
|
'description' => ['nullable', 'string'],
|
|
'link' => ['nullable', 'url', 'max:255'],
|
|
'recurrence_type' => ['nullable', Rule::enum(RecurrenceType::class)],
|
|
'recurrence_day_of_week' => ['nullable', 'string', 'max:255'],
|
|
'recurrence_day_position' => ['nullable', 'string', 'max:255'],
|
|
'recurrence_interval' => ['nullable', 'integer'],
|
|
'recurrence_end_date' => ['nullable', 'date', 'after_or_equal:start'],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @return array<string, string>
|
|
*/
|
|
public function messages(): array
|
|
{
|
|
return [
|
|
'meetup_id.exists' => 'Das angegebene Meetup existiert nicht.',
|
|
];
|
|
}
|
|
}
|