R
R
Rishat Sultanov2017-04-11 00:00:34
Laravel
Rishat Sultanov, 2017-04-11 00:00:34

How to add a route to the admin panel?

Good afternoon, ladies and gentlemen.
There is an admin panel
It has the following group implementation

Route::group(['prefix' => 'admin'], function () {
    Voyager::routes();

    
});

How to add a separate view to it? So that it can be seen only after logging into the admin panel.
Now everyone can get access to this route :)
Route::get('/admin/needfixfilter', function () {
    return view('needfixfilter');
});

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
kpa6uu, 2017-04-11
@rishatss

Attach a middleware to the desired route / group of routes, in which the authorization check will take place.

A
Andrzej Wielski, 2017-04-11
@wielski

Docks, read the docks!
https://the-control-group.github.io/voyager/docs/0...
And also look at the implementation of the package itself:
vendor/tcg/voyager/src/Http/Middleware/VoyagerAdminMiddleware.php
vendor/tcg/ voyager/routes/voyager.php
As you can see, admin routes are stored in a group:

Route::group(['middleware' => 'admin.user'], function() {

});

As for checking user capabilities, see any built-in controller, for example:
vendor/tcg/voyager/src/Http/Controllers/VoyagerMenuController.php
Voyager::canOrFail('edit_menus');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question