Setup Menus in Admin Panel

  • No products in the cart.


Logout and Dashboard Section

Logout section:

Similar to the showLoginForm, you cannot modify in the vendor section so copy the function logout part and add it to the LoginController.php

public function logout(Request $request)


return $this->loggedOut($request) ?: redirect()->route('login');


Don’t forget to add the following line of code at the top of the LoginController.php code:

use Illuminate\Http\Request;

As soon as when you click the logout button you will redirect to the login page.



Dashboard section:

After the successful login, it should be redirected to the dashboard.
For this, you can simply provide the url path in the LoginController.php.
In this case, you can’t provide the route path.

protected $redirectTo = 'admin/dashboard';

Till now login section is almost completed but logout section is still not completed.

So go to the directory resources/views/admin/layout/master.blade.php and find out the logout section.
Now run the url http://newsportal.test/home and click on the logout section then right click to inspect the code. Then you will see the following result and copy the outerHTML and paste it to the master.blade.php below the tag <a>…</a>

<a href="#" onclick="event.preventDefault();
document.getElementById('logout-form').submit();" class="dropdown-item">








And copy the form also which is below the logout section:

<form id="logout-form" action="http://newsportal.test/logout" method="POST" style="display: none;">
<input type="hidden" name="_token" value="CYMGpxOloARikXmdCJc8HBfo84RHACwAPghA3uPE">


and make the path dynamic:

action="{{ route('logout') }}"

and the input field shouldn’t be displayed. So perform the following:

{!! csrf_field() !!}

So after clicking the logout section, you will redirect to the login page.




Suppose, when we run the url http://newsportal.test/admin/dashboard you will redirect to the dashboard. But in our real work project, this shouldn’t happen.So when we run the url http://newsportal.test/admin/dashboard it should redirect to the login page for this purpose we use the middleware.
Go to the web.php and add the middleware function as in below screenshot below:



We can also optimize the path by using the prefix as below:

Route::group([ 'prefix' => 'admin/', 'as' => 'admin.', 'middleware' => 'auth'],function()




Now adding the route for news, edit, update and delete

Route::get('user/store', [ 'as'=> '', 'uses' => 'Admin\[email protected]']);
Route::get('user/edit/{id}', [ 'as'=> 'user.edit', 'uses' => 'Admin\[email protected]']);
Route::get('user/update/{id}', [ 'as'=> 'user.update', 'uses' => 'Admin\[email protected]']);
Route::get('user/delete/{id}', [ 'as'=> 'user.delete', 'uses' => 'Admin\[email protected]']);



SEE ALL Add a note
Add your Comment

Advanced Course Search Widget

Popular Courses

Course Categories

© PHPhelp. 2002 - 2018 All rights reserved.