- 🏗️ Introduced CoursePolicy and CourseEventPolicy for authorization.

-  Added `StoreCourseRequest` and `UpdateCourseRequest` for structured validation.
-  Introduced `StoreCourseEventRequest` and `UpdateCourseEventRequest` for consistent request validation.
- 🖼️ Created `CourseResource` and `CourseEventResource` for API responses.
- 🔄 Refactored `CourseController` and `CourseEventController` to use Policies and FormRequests.
-  Added dedicated `uploadLogo` and `uploadAvatar` API endpoints with shared media validation.
- 🚀 Improved API by aligning Course and CourseEvent behavior with other entities.
This commit is contained in:
HolgerHatGarKeineNode
2026-06-15 15:06:07 +02:00
parent 119deb4f5c
commit 1518611bdb
25 changed files with 1186 additions and 256 deletions
@@ -0,0 +1,39 @@
<?php
namespace App\Http\Resources;
use App\Models\CourseEvent;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
/**
* @mixin CourseEvent
*/
class CourseEventResource extends JsonResource
{
/**
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return [
'id' => $this->id,
'course_id' => $this->course_id,
'venue_id' => $this->venue_id,
'from' => $this->from,
'to' => $this->to,
'link' => $this->link,
'course' => $this->whenLoaded('course', fn (): array => [
'id' => $this->course->id,
'name' => $this->course->name,
]),
'venue' => $this->whenLoaded('venue', fn (): array => [
'id' => $this->venue->id,
'name' => $this->venue->name,
]),
'created_by' => $this->created_by,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
];
}
}
+30
View File
@@ -0,0 +1,30 @@
<?php
namespace App\Http\Resources;
use App\Models\Course;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
/**
* @mixin Course
*/
class CourseResource extends JsonResource
{
/**
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return [
'id' => $this->id,
'name' => $this->name,
'lecturer_id' => $this->lecturer_id,
'description' => $this->description,
'logo' => $this->getFirstMediaUrl('logo', 'thumb'),
'created_by' => $this->created_by,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
];
}
}
+1
View File
@@ -32,6 +32,7 @@ class LecturerResource extends JsonResource
'node_id' => $this->node_id,
'paynym' => $this->paynym,
'team_id' => $this->team_id,
'avatar' => $this->getFirstMediaUrl('avatar', 'thumb'),
'created_by' => $this->created_by,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,