mirror of
https://github.com/HolgerHatGarKeineNode/einundzwanzig-app.git
synced 2026-06-15 16:00:30 +00:00
✨ **Add authenticated API endpoints for managing Meetups, Cities, Venues, and Lecturers**
- ➕ Introduced `store`, `update`, `mine`, and `mineShow` endpoints for `Meetups`, `Cities`, `Venues`, and `Lecturers` with validation and authorization. - 🔒 Added `Policies` for `Meetups`, `Cities`, `Venues`, and `Lecturers` leveraging `ChecksCreatorOwnership` for ownership checks. - 🌐 Created `Resources` for structured API responses: `MeetupResource`, `CityResource`, `VenueResource`, and `LecturerResource`. - ✅ Added dedicated `Request` classes for input validation: `Store` and `Update` variants for all models. - 🛠️ Updated controllers to support new functionalities with localized error messages and proper HTTP responses.
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use App\Models\City;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
/**
|
||||
* @mixin City
|
||||
*/
|
||||
class CityResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'country_id' => $this->country_id,
|
||||
'name' => $this->name,
|
||||
'slug' => $this->slug,
|
||||
'longitude' => $this->longitude,
|
||||
'latitude' => $this->latitude,
|
||||
'population' => $this->population,
|
||||
'created_by' => $this->created_by,
|
||||
'created_at' => $this->created_at,
|
||||
'updated_at' => $this->updated_at,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use App\Models\Lecturer;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
/**
|
||||
* @mixin Lecturer
|
||||
*/
|
||||
class LecturerResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'name' => $this->name,
|
||||
'slug' => $this->slug,
|
||||
'subtitle' => $this->subtitle,
|
||||
'intro' => $this->intro,
|
||||
'description' => $this->description,
|
||||
'active' => $this->active,
|
||||
'website' => $this->website,
|
||||
'twitter_username' => $this->twitter_username,
|
||||
'nostr' => $this->nostr,
|
||||
'lightning_address' => $this->lightning_address,
|
||||
'lnurl' => $this->lnurl,
|
||||
'node_id' => $this->node_id,
|
||||
'paynym' => $this->paynym,
|
||||
'team_id' => $this->team_id,
|
||||
'created_by' => $this->created_by,
|
||||
'created_at' => $this->created_at,
|
||||
'updated_at' => $this->updated_at,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use App\Models\MeetupEvent;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
/**
|
||||
* @mixin MeetupEvent
|
||||
*/
|
||||
class MeetupEventResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'meetup_id' => $this->meetup_id,
|
||||
'start' => $this->start,
|
||||
'location' => $this->location,
|
||||
'description' => $this->description,
|
||||
'link' => $this->link,
|
||||
'recurrence_type' => $this->recurrence_type,
|
||||
'recurrence_day_of_week' => $this->recurrence_day_of_week,
|
||||
'recurrence_day_position' => $this->recurrence_day_position,
|
||||
'recurrence_interval' => $this->recurrence_interval,
|
||||
'recurrence_end_date' => $this->recurrence_end_date,
|
||||
'created_by' => $this->created_by,
|
||||
'created_at' => $this->created_at,
|
||||
'updated_at' => $this->updated_at,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?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,
|
||||
'last_event_at' => $this->last_event_at,
|
||||
'created_by' => $this->created_by,
|
||||
'created_at' => $this->created_at,
|
||||
'updated_at' => $this->updated_at,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use App\Models\Venue;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
/**
|
||||
* @mixin Venue
|
||||
*/
|
||||
class VenueResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'city_id' => $this->city_id,
|
||||
'name' => $this->name,
|
||||
'slug' => $this->slug,
|
||||
'street' => $this->street,
|
||||
'created_by' => $this->created_by,
|
||||
'created_at' => $this->created_at,
|
||||
'updated_at' => $this->updated_at,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user