Skip to content
Docent Docs

Web Admin

Setup

Enable the database store and the admin panel, then define the gate that guards it.

The admin panel needs three things: the database tables, two config flags, and a gate that decides who may open it.

Publish the migrations

The installer publishes the store migrations when you pass --with-database:

bash
php artisan docent:install --with-database

That publishes the docent_pages and docent_page_revisions migrations. (You can also run vendor:publish --tag=docent-migrations.) Then migrate:

bash
php artisan migrate

Stored pages carry a site column, and page identity is the (site, slug) pair. On a single-site install everything lands under the shipped docs key and you'll never see it; on a multi-site install it's what lets each site keep its own billing/refunds page.

Enable the store and the panel

The database store is a shared setting; the panel belongs to a site. Flip both in config/docent.php:

php
'database' => [
    'enabled' => true,
    'connection' => null,
],

'sites' => [
    'docs' => [
        // ...
        'admin' => [
            'enabled' => true,
            'path' => 'admin',
            'gate' => 'viewDocentAdmin',
            'disk' => 'public',
        ],
    ],
],

database.enabled turns on the store that composes over your files, and admin.enabled mounts that site's panel. Leave connection as null to use your default database connection. On a multi-site install each site declares its own admin block, so every site gets its own panel, and each panel can be guarded by a different gate.

Define the gate

Every admin route, the panel and its JSON API alike, is guarded by the gate ability, and gates deny guests by default. Define it in a service provider:

php
use Illuminate\Support\Facades\Gate;

Gate::define('viewDocentAdmin', function ($user) {
    return $user->is_admin;
});

Return true for the users who should reach the panel. Until you define this gate, the panel denies everyone.

The admin path

The panel is served under admin.path inside its site's route group, so the shipped docs site puts it at /docs/admin, and a site served at /help would put its panel at /help/admin. Because it sits inside that group, a docs page with the exact slug admin would be shadowed by the panel. docent:check warns you if you ever create one.

With the panel live, learn your way around it in editing.