Adding different links to a blade template based on the guard - laravel

I have set up custom guards for my app using the laravel Auth.
I already have a custom 404.blade.php in resources\views\errors.
Auth::guard('admin')->User() with home route as abc.com/admin
and
Auth::guard('portal')->User() with home route as abc.com/portal
I'm trying to set up 404 pages for them, or at least create a single 404 page with a link to 'home' which should take them to their homepage.
I'm currently on laravel 5.4

Try creating a single blade file for your 404 and put this code in it to redirect to your multiple home pages based on the guard:
#if(Auth::guard("admin")->check())
home
#elseif(Auth::guard('portal')->check())
home
#endif

Related

How can I define authentication related routes in laravel8?

I followed tutorials and using the below commands I installed all the files needed for register user, login, etc:
composer require laravel/ui
php artisan ui vue --auth
now I have Auth directory in my controllers list and also new forms for register users, login, home and etc are automatically created, I added a link on my page to enter me to registration form, but when I add user, after I hit the register button it says home not found and shows me 404 error which is about route, where I have added Auth::routes(); already to my web blade page. I checked the database, the user is successfully added to the table.
You must add redirectTo property to your auth controller. It's default to /home and you're getting 404 cause you don't have this route.

How to redirect to a blade dashboard page from Vue login Component page after successfully login in laravel JetStream?

I created a laravel 8 project using jetstream authentication. As stack I have used inertia+vue. After successful login, I need to redirect to a blade file. But the problem is when I redirect to the blade file, the blade file opens as a modal like the image attached below. And the URL doesn't change (I mean the browser doesn't get refreshed). I would be grateful if you can suggest me the solution. Thanks in advance.
I eventually found this that allowed me to redirect to a page directly from a controller without it appearing in a modal—https://inertiajs.com/redirects#external-redirects.
Example:
return Inertia::location($url);

Handling multiple views controllers in CodeIgniter 4

I am new to CodeIgniter 4.
I have one controller named Pages and helps to display website pages normally. Then I have another controller named Admin which is suppose to load the admin view with its own header and footer files.
While Pages controller works fine, the Admin controller keeps saying 404-file not found admin.
I think I have a problem with my current Route settings below. Please help.
$routes->setDefaultController('Pages');
$routes->setDefaultMethod('default');
// Route Definitions
$routes->get('/', 'Pages::index');
$routes->get('(:any)', 'Pages::default/$1');
try ajusting your code like this.
$routes->setDefaultController('Pages');
$routes->setDefaultMethod('default');
// Route Definitions
$routes->resource('pages');
$routes->get('/', 'Pages::index');
$routes->get('(:any)', 'Pages::default/$1');

Building on Laravel API backend and Vuejs frontend

I would require a little help here if this method will work out well.
Firstly, I have a backend API server created using Laravel and Laravel Passport. Secondly, I have also created the frontend with Vuejs within the same project. As such, I will be required to use both the api.php and web.php routes. I am also redirecting these routes using vue-router.
Backend
Inside the web.php routes, I have used two different routes because I want to display generic contents on my landing site and the other as an authentication required dashboard.
Example:
web.php
As above, this is to capture the routes which are 404 Not Found that are directly manipulated in the address bar to redirect correctly to their respective pages. I also ended up having two different blade templates named as dashboard.blade.php and home.blade.php respectively. Is this an okay practice for a Laravel-Vuejs project? Or are there ways that you would like to recommend?
dashboard.blade.php
home.blade.php
Login related problem with login page using the layout of the landing page into another layout of the dashboard page
The problem that I am faced with when doing an API login with the password grant is that the login page does not redirect to the dashboard page properly. The URL route does change but the page is rendered as blank.
The login using axios here:
I have managed to fix the problem.
In web.php, since we have
Route::get('/dashboard/{any?}', function () {
return view('dashboard');
})->where('any', '^(?!.*api).*$[\/\w\.-]*');
Inside of my Login.vue redirect handler, I use location.href = '/dashboard' instead of this.$router.push('dashboard').

how to get the admin login page by inserting /ci-admin like /wp-admin in wordpress

I am wondering if that is possible to view the admin login page just by typing /CI_ADMIN after the domain name just like we do in wordpress.
http://www.abc.com/wp-admin
and I want to do
http://www.abc.com/ci-admin
for my codeigniter website. is that possible ? the url thing
you can do this with routes just define route in you routes.php file
$route['ci-admin'] = 'ci_admin/login';
for more how to create admin panel please read this article specially third method
CI Admin panel

Resources