How to create admin panel in laravel

Rakesh Sharma      6 Comments  

How to create admin panel in laravel 5 or interface in laravel 5

How to create admin panel in laravel

Admin Panel :-

A restricted interface which will be accessed by owner/administrator roles who can control the site.

Every sites need a back-end or admin interface to control sites or for keep sites dynamic. In laravel we can make admin panel easily but in different way like other php framework Codeigniter, yii etc. We can access directly admin sub-directory using url in other frameworks but in laravel for access admin panel or interface we need namespace defines. There is more different ways to create an admin panel but i am sharing a simple way for how to create admin panel in laravel 5 or admin interface in laravel 5.

Steps to set up admin panel in laravel 5 :-

1. Create folder structure : Separate All of your admin files(controllers/views) in a directory named “admin” so structure will be
app>controllers>admin (your all admin controllers)
app>views>admin (your all admin views)


2. Initialize namespace : Laravel 5 has much stricter about namespace standards rather then Laravel 4. This means that changing folder structure also changes the namespace the autoloader looks in for a class. In this case, you’ve added the namespace Admin to your Controller.

Your declaration of namespace should be like:-

// namespace App\Http\Controllers; //sample controller decl 
namespace App\Http\Controllers\Admin;

Let’s create a example controller inside “Http/Controller/Admin/LoginController.php”

namespace App\Http\Controllers\Admin; //admin add
use App\Http\Controllers\Controller; // using controller class
class LoginController extends Controller {
  public function index() {
    return \View::make('admin.login');

3. Setup Routes : Now we need to setup routes for our admin panel so in your "Http/routes.php" file make your rotes like below

// route to show the login form
Route::group(array('namespace'=>'Admin'), function()
    Route::get('/admin', array('as' => 'admin', 'uses' => 'LoginController@index'));

Using group routing we can make easy routing inside a folder for more about Group routing

You can set more routes same as in the group routing like:-

// route to show the login form
Route::group(array('namespace'=>'Admin'), function()
    Route::get('/admin', array('as' => 'admin', 'uses' => 'LoginController@index'));
    Route::get('/admin/register', array('as' => 'register', 'uses' => 'LoginController@register'));

Now you can access your admin panel or interface by url you can make different default page i am sharing only a simple way to access admin panel in laravel 5.

  • Pawan Joshi

    Excellent tutorial of Admin Panel for laravel 5

  • paul felix

    good tutorial, thanks, but where can i put the css and js files of the admin panel template, in the public folder just as the other ones?

  • adminarchitect

    new interesting admin panel –

  • cloverink

    Hi, i already follow your steps. it was beautiful! but i have some questions. Only admin can login to the admin page, such as username : admin, and password : admin. But how to make it so from the backend? So that I don’t need to register admin anymore. thanks

  • Alankar Singh

    I have tried the same steps but getting the following errors : Class AppHttpControllersAdminLoginController does not exist
    Anyone have idea about this error.

  • Mehul Mirani

    How to get admin user id in controller.