I am trying to create a maintanance mode for the editors to easily adapt. In the future I will adjust to only route if the user is not logged in so editors would still see the page. But currently I am testing the route only based on the toggle inside my panel.
While this works inside a template:
<?= $site->maintanance()->toBool() ? 'Maintenance mode' : 'Page running normally' ?>
This does not inside config.php:
'routes' => [
[
'pattern' => '(:all)',
'action' => function ($path) {
$site = site();
if ($site->maintanance()->toBool()) {
if ($path === 'maintanance') {
return Page::factory([
'slug' => 'maintanance',
'template' => 'maintanance',
'model' => 'maintanance',
'content' => [
'title' => 'Maintenance',
'uuid' => Uuid::generate(),
]
]);
}
return go('/maintanance');
}
}
]
]
I am guessing that I cannot access blueprint fields like this in config.php. Is there another way to do this?