You can give your admin classes their own namespace, for example App\Admin\Http\Controllers\PostsController. Or you can do it like so App\Http\Controllers\Admin\PostsController. That is up to you. The last one is easier, since you don't have to adjust anything for reading your routes.
exclude admin panel as folder
Because I would like to have my admin panel be seperated from the main application I would like to seperate the whole admin panel to a folder(admin). This makes it easier for me to set for example some rules on my server, so I can only access the admin direction when I'm connected to my server and use a tunneled connection.
What's the best way to exclude all controllers/models/views to another folder so I exclude all main content of admin panel from main app.
@jaheller You don’t need to include admin in the route pattern if you’ve added a prefix of admin to the group, otherwise the route will be /admin/admin. Run php artisan route:list and you will see what I mean.
In your case, you’ll need to do this:
Route::group(['namespace' => 'Admin', 'prefix' => 'admin'], function () {
Route::get('/', 'AdminController@index')->name('admin.index'); // Will match /admin/
});
You’ll probably also want to stick some middleware on that group to ensure only authenticated administrators can view admin routes.
Please or to participate in this conversation.