Voyager 2
2.x
2.x
  • Introduction
  • Javascript
  • Media Manager
  • Plugins
  • Settings
  • bread
    • Actions
    • BREAD Builder
    • Layouts
    • Lists
    • Manipulate data
    • Multilanguage
    • Relationships
    • Validation
    • Views
  • contributing
    • Assets
    • CSS
    • Introduction
  • de
    • index
  • formfields
    • Checkboxes
    • Date & Time
    • Dynamic input
    • Formfields
    • Media Picker
    • Number
    • Password
    • Radios
    • Relationship
    • Repeater
    • Select
    • Simple array
    • Slider
    • Slug
    • Tags
    • Text
    • Toggle
  • getting-started
    • Installation
    • Prerequisites
    • Tips and tricks
    • What is Voyager
  • overriding
    • Overriding formfields
    • Icons
  • plugins
    • Assets
    • Components
    • Features
    • Filter
    • Plugin development
    • Language
    • Menu Items
    • Custom pages
    • Preferences
    • Routes
    • Settings
    • Widgets
Powered by GitBook
On this page

Was this helpful?

  1. plugins

Custom pages

PreviousMenu ItemsNextPreferences

Last updated 3 years ago

Was this helpful?

This page shows how to add a custom page with a component only to logged-in users. You need to define and register a and add a to Voyager if you want.

use Illuminate\Support\Facades\Route;
use Inertia\Inertia;
use Voyager\Admin\Contracts\Plugins\Features\Provider\ProtectedRoutes;

class MyPlugin implements ProtectedRoutes
{
    public function provideProtectedRoutes(): void
    {
        Route::get('my-page', function (Request $request) {
            // Trigger Voyager to inject some necessary dynamic data
            Inertia::setRootView('voyager::app');

            return Inertia::render('my-component', [
                'data' => []
            ])->withViewData('title', 'My page');
        });
    }
}
component
menu-item