EscolaLMS/H5P

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

Summary

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

namespace EscolaLms\HeadlessH5P\Http\Requests;

use EscolaLms\HeadlessH5P\Models\H5PContent;
use Illuminate\Support\Facades\Gate;

class AdminContentReadRequest extends ContentReadRequest
{
    public function authorize(): bool
    {
        $h5pContent = $this->getH5PContent();

        return Gate::allows('read', $h5pContent);
    }

    public function getH5PContent(): H5PContent
    {
        return H5PContent::findOrFail($this->route('id'));
    }
}