Files
laravel-manager/src/Modules/Pages/PagesModule.php
T

47 lines
1.1 KiB
PHP

<?php
namespace IriksIT\Manager\Modules\Pages;
use IriksIT\Manager\Models\Page;
use IriksIT\Manager\Modules\BaseModule;
use IriksIT\Manager\Support\MediaUsage;
use IriksIT\Manager\Support\Permission;
class PagesModule extends BaseModule
{
public function key(): string
{
return 'pages';
}
public function label(): string
{
return 'Pages';
}
public function enabledByDefault(): bool
{
return false;
}
public function permissions(): array
{
return [
new Permission('pages.edit', 'Change the texts of the pages', 'Site content'),
];
}
public function navigation(): array
{
return [
['label' => 'Pages', 'route' => 'manager.pages.index', 'permission' => 'pages.edit'],
];
}
/** Where the media library looks for the use of a file: the texts of the pages. */
public function boot(): void
{
app(MediaUsage::class)->register(fn () => Page::query()->get(['body'])->flatMap(fn (Page $row) => array_values($row->only(['body']))));
}
}