EscolaLMS/Courses-Import-Export

View on GitHub
src/Http/Requests/CloneCourseAPIRequest.php

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
<?php

namespace EscolaLms\CoursesImportExport\Http\Requests;

use EscolaLms\CoursesImportExport\Models\Course;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Gate;

class CloneCourseAPIRequest extends FormRequest
{
    public function authorize()
    {
        $course = $this->getCourse();
        return Gate::check('clone', $course);
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [];
    }

    public function getCourse(): ?Course
    {
        return Course::findOrFail($this->route('course'));
    }
}