mirror of
https://github.com/HolgerHatGarKeineNode/einundzwanzig-app.git
synced 2026-06-17 16:40:31 +00:00
1518611bdb
- ✨ 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.
33 lines
596 B
PHP
33 lines
596 B
PHP
<?php
|
|
|
|
namespace App\Policies;
|
|
|
|
use App\Models\Course;
|
|
use App\Models\User;
|
|
use App\Policies\Concerns\ChecksCreatorOwnership;
|
|
|
|
class CoursePolicy
|
|
{
|
|
use ChecksCreatorOwnership;
|
|
|
|
public function viewAny(User $user): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public function view(User $user, Course $course): bool
|
|
{
|
|
return $this->owns($user, $course);
|
|
}
|
|
|
|
public function create(User $user): bool
|
|
{
|
|
return (bool) $user->is_lecturer;
|
|
}
|
|
|
|
public function update(User $user, Course $course): bool
|
|
{
|
|
return $this->owns($user, $course);
|
|
}
|
|
}
|