Make admin directory be the default directory laravel - laravel

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'); });

Related

I can't access the Voyager admin panel after installing

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.

How to create a subfolder inside controller and view folders in codeigniter?

I wanted to create a folder named 'schoollevel' inside controller and view folder to create a separate module containing login function and profile views to provide another login functionality for some users. The 'schoollevel' contains all the files for login and profile view. Can anyone suggest how to do this ? I want the control to go to the separate folder.
Its Easy to create folder in controller and view in codeigniter.
Folder name : school
1.create a login controller
application->controller->school->Login.php
create a login view
application->view->school->login.php
Now, How to call view file
Inside login controller in the index() function add
this to call login.php view
$this->load->view('school/login');
I hope this help you!

Restricting access to a page if user isn't logged in with Laravel 5.4

I've created a Dashboard page and i want it to be accessed only if an user is logged in. The login and register were made with the php artisan make:auth command. Any tips or ideas how to accomplish this ?
Just add the Auth middleware to your route
Route::get('dashboard', function () {
//whatever
})->middleware('auth');
Make sure you have
use Auth; in your routes
In Your web.php route, you can add
Route::get('complaintSuggestion', function() {
return view('patials.complaintSuggestion');
})->middleware('auth');

Laravel - can we create a master route that redirects every link to the profile page if the same has not been filled in as yet

In laravel, I want the users to create their profile before they can access any other link of the application. Can we create a master route that redirects every link to the profile page if the same has not been filled in as yet.
You would have to wrap all your routes in a middleware that checks if their profile has been filled, if this fails then redirect them to the profile page.
one Possible solution would be this :
Create a variable for each user to say true if his profile is filled or false if not.
then create a middleware to check that variable. if its false to redirect to profile page... your logic. read here for middleware https://laravel.com/docs/5.4/middleware
wrap all your routes with that middleware
in your route file
Route::group(['middleware' => 'yourmiddlewarename'], function() {
//all routes
});

laravel prefix not working in route

Route::group(array('prefix'=>'admin','middleware' => 'auth_admin_check'), function() {
Route::any("dashboard",["as"=>"admin_login_post1","uses"=>"admin\DashboardController#index"]);
});
after login i am redirecting to the page: dashboard but my prefix : 'admin' was not added.
I think you're redirecting to a url? Do you redirect to '/dashboard'? This will not prefix it.
What you should use is
redirect(route('admin_login_post1'))
This will retrieve the url by the route's name. Laravel will find the route in a group with a prefix, so Laravel will prefix the URL.
The route() function is very usefull. When you change a url, you don't have to change it troughout your whole application. This is because the function retrieves the url from the routes file. So if you change it in the routes file, you change all the links in your application.
if your prefix "admin" is not loading in the URL, then may be there is another route declared for /dashboard. check for that
and for redirection, use
redirect()->route('admin_login_post1');

Resources