mirror of
https://github.com/HolgerHatGarKeineNode/einundzwanzig-app.git
synced 2026-06-11 02:50:29 +00:00
3b93e22e95
- ➕ 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.
18 lines
413 B
PHP
18 lines
413 B
PHP
<?php
|
|
|
|
namespace App\Policies\Concerns;
|
|
|
|
use App\Models\User;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
trait ChecksCreatorOwnership
|
|
{
|
|
/**
|
|
* Nur der urspruengliche Ersteller (created_by) oder ein Super-Admin darf das Model veraendern.
|
|
*/
|
|
protected function owns(User $user, Model $model): bool
|
|
{
|
|
return (int) $model->created_by === $user->id || $user->hasRole('super-admin');
|
|
}
|
|
}
|