0

2 years agoby Richard Opoku

Creating Custom Logout for Admins table

Since the the admins table and users table are different, why is it that a user logging out affects an admin who is still logged out.

22

Sarthak replied 2 years ago

0

@KamranAhmed You need to create a function for admin logout and in that give guard('admin') when you logout.

public function logout(){
	return auth->guard('admin')->logout();
}

0

Kamran Ahmed replied 2 years ago

0

Sir, I have created the log-out button for admin (which you haven't specified in the video), but it is not working properly. Problem is, when I log-out as admin, it's log out as user also, again if I log-out as user, it log out from admin also. Why is this happening, I'm stuck. Can you please tell me how to fix it? here's the screen-shot of my code.

0

Bhaskar das replied 2 years ago

0

thanks. that helps

0

Ajith kumar Y replied 2 years ago

0

HI....This is Ajithkumar from Coimbatore.Bro how to create search bar in laravel 5.4.i have a professionals list,i would like to filter them in my index page. Not in table. i hope that you can understand my english. Please..help me ....

0

Rorisang Maimane replied 2 years ago

0

Thank yo so far i understand except the artisan command. What artisan command? I do not mean to be otherwise but i am learning laravel and php.

I followed your examples in the tutorials and only for this i am not able to go through. When i copy the details of users manually i get errors to say user credetials do not match our records even if i copied the password and email correctly.

I am thinking, isn't there a best way to register as admin from the website? or the option where i can go to the database table and make user admin?

22

Sarthak replied 2 years ago

0

Okay got your point, for the first time what you can do, go to phpmyadmin and manually fill columns for admin table and for password you can copy bcrypted password from user table (as yo have registered a user).

In this was you have your first field on your admin table.

For a real project, you should make an artisan command which generate a admin for the first time so that your client don't have to touch database.

0

Rorisang Maimane replied 2 years ago

0

Look at it this way for understanding. I cloned/downloaded your github code. I installed composer, generated key to the env file and then ran the migrations. The blog is up and running. So now i registered a user. How do i get to admin dashboard/home. Remember that i am able to register users but the is no admin since it has separate table. how do i get my user to be admin?

22

Sarthak replied 2 years ago

0

You mean, register new admin user ?

0

Rorisang Maimane replied 2 years ago

0

i need clarity on something. How do i make user admin?

22

Sarthak replied 2 years ago

0

Great. If your question is properly answered, then please select reply as best reply and if you don't want to get new replies then close this discussion also.

0

Richard Opoku replied 2 years ago

0

It works. Thank you

22

Sarthak replied 2 years ago

0

You can create a new route like

	Route::get('admin-logout','Admin\LoginController');

Then on Admin\LoginController Create a new function like

		public function logout()
		{		
			$this->guard('admin')->logout();	
		}

This will only logout admin not user. Try this and if you still have any problem please do reply here.

Ask Question
Most Visited
Categories