I tried hard-coding an admin panel in my Laravel project only to find out about Voyager.
So I installed voyager on my project (the admin panel files are still there).
However, every time I test it out by going to mydomain.test/dashboard/login , it keeps going back to my site's index page.
Do you think it has something to do with my hardcoded admin panel files? The files are inside the project folder prior to installing voyager.
Or I'm missing something here?
I changed the route's prefix into 'dashboard' instead of 'admin' because my hardcoded admin panel is using 'admin'.
Route::get('/', function () {
return view('front');
});
Route::group(['prefix' => 'dashboard'], function () {
Voyager::routes();
});
I want to access the Voyager admin panel.
[UPDATE]
I have finally resolved this issue by simply adding a new user and grant admin access to it.
your url it's not good.
try "mydomain.test/admin/login" or "mydomain.test/admin"
be careful, create the first user from the command line.
Related
I am creating a Laravel project for the users. Laravel has its own laravel/ui package, but I am creating its admin panel too, and I am a bit confused about what I should do for admins. Also, I am confused about the security for the admin panel. So there are 2 solutions in my mind:
Add a new column in the user's table named status, and if its value is admin, he can access the admin panel; otherwise, redirect to the homepage.
Create a separate admins table and improve laravel/ui auth. For that, I found documentation here.
What should I do? Even i have added table prefix for tables in .env & config/database.php. I am afraid that the hackers/users should not access the admin panel. And also, tell me if the table prefix is good for security, or should I remove the table prefix?
You need the permission-roles system.
https://spatie.be/docs/laravel-permission/v4/introduction
This is good decision for you. With well-configured routes no one wont have access in admin panel without access in data base.
For example, in panel page only admin have access:
Route::name('adminspace.')->group(['middleware' => ['role:admin']], function () {
Route::view('/panel', 'pages.panel');
});
How can I make an admin directory be the default directory when website is loaded? I'm using laravel-admin as admin panel and I can access it by console.siteexample.com/admin, but how can I change it to access it only with console.siteexample.com ? Which is the best way to this?
Make an index view on the view directory.
and define the home route on the web.php file.
Route::get('/', function () {
return view('index'); });
How can I add a subdomain to Admin Panel Laravel Backpack?
I want to add a subdomain to my Laravel Backpack admin panel, I need point 'admin.example.com' subdomain to Laravel Backpack admin Panel.
Laravel Backpack provides route prefix for Admin Panel.
I want to use the same project source code for the site, admin and API.
admin.example.com -> Admin
api.example.com -> API
www.example.com -> Site
You can get Laravel Backpack to run under a subdomain, for example admin.app.local, instead of the prefix (for example app.local/admin) as follows:
In the .env file, you can define the admin subdomain, something useful if you work in different environments where it changes:
ADMIN_SUBDOMAIN = admin.app.local
Optionally you can also define in config/app.php, whether or not the admin will use subdomain, adding:
'use_admin_subdomain' => true,
Then in the config/backpack/base.php file, you will want to stop using the admin route prefix, since you will use admin in the subdomain, so you must define:
'route_prefix' => '',
Then in routes/backpack/custom.php, you will be able to include all routes under a new group, which will determine if the admin backpack runs under a subdomain (defined in app.use_admin_subdomain) and the subdomain (defined in env('ADMIN_SUBDOMAIN'), and all the original routes and groups will go within:
Route::group (
config('app.use_admin_subdomain') ? ['domain' => env('ADMIN_SUBDOMAIN')]: []
, function () {
... original backpack routes
});
Optionally in the same backpack routes file, you can remove the prefix of the original routes, commenting:
'prefix' => config ('backpack.base.route_prefix', 'admin'),
Although being empty in config/backpack/base.php has no effect yet without commenting.
You can follow the same procedure to define your API routes under the api.app.local subdomain, in that case in routes/api.php file.
I would like to have different login view for different subdomain.
My system has 2 modules for login.
-Member: www.example.com
-Agent: agent.example.com
I would like to implement 2 different login layout also different flow but using same users table.
-Member: www.example.com/login
-Agent: agent.example.com/login
inside my routes/web.php
Route::domain('agent.example.com')->group(function () {
Route::get('/login', 'AgentController#showLoginForm')->name('agent.login');
});
However, it still show my member login screen.
But if I changed to
Route::domain('agent.example.com')->group(function () {
Route::get('/agent-login', 'AgentController#showLoginForm')->name('agent.login');
});
It display the correct controller and view.
I already added the Route::domain to filter up. But how come Laravel still pick up the original login route?
How do I separated it? I prefer to have agent.example.com/login instead of agent.example.com/agent-login
It is because I am using acacha/adminlte-laravel packages. It has the login route included in the package.
Laravel route is organized based on priority of matching. So you want your route match first, you have to put in on the top.
And due to acacha/adminlte-laravelset the Auth::route inside the package. So I can't manually set the route priority in web.php.
What you have to do is remove the Auth::route in vendor. Fork your own repo. and do the customization.
I am using the great charima bundle to the laravel framework 3.2.
How can I add a login page to the /admin page?
Charisma is not an administration panel in itself. It is simply a user-interface (or theme, whichever you prefer) that you can use for your own administration panel. You will need to build your own panel that makes use of it.
Please consider looking at the Laravel Auth Usage Documentation for further information on using authentication and protecting your admin route.
Route::get('admin', array('before' => 'auth', function() {}));