Laravel Admin Panel Installation Tutorial

Jul 23, 2024

Laravel Admin Panel Installation Tutorial

Introduction

  • Presenter: Yamin
  • Objective: Install an admin panel in a Laravel project easily
  • Outcome: Display, edit, delete, or update data in the admin panel

Steps for Installation

1. Create Laravel Project

  • Open Command Prompt (CMD)
  • Run command to create a fresh Laravel project:
    laravel new lara_admin_panel
    
  • Navigate to the project directory:
    cd lara_admin_panel
    
  • Start the Laravel server:
    php artisan serve
    

2. Database and Migration

  • Open another Command Prompt in the project directory
  • Create and migrate tables:
    php artisan migrate
    
  • The default database will be named lara_admin_panel
  • Verify the database and migrated tables in phpMyAdmin

3. Install Laravel Package for Admin Panel

  • Install Open Admin package:
    composer require open-admin-org/open-admin
    
  • Publish vendor files:
    php artisan vendor:publish --provider="OpenAdmin\ServiceProvider"
    
  • Run Admin installation command:
    php artisan admin:install
    
  • Default admin login credentials:
    • Username: admin
    • Password: admin

4. Accessing Admin Panel

  • Go to /admin in browser and login using admin credentials

5. Adding User Data

  • Install Open Admin Helper for easier setup:
    composer require open-admin-ext/helpers
    php artisan admin:import helpers
    
  • Refresh Admin Panel to see the new Helpers menu option
  • Use Scaffold option to create tables, models, and controllers:
    • Example: Creating table students
    • Fill out fields: name, email, image
    • Submit and add the resource route to app/admin/routes.php
    Route::resource('students', 'StudentController');
    

6. Configure File Upload

  • Modify config/filesystem.php:
    'admin' => [
        'driver' => 'local',
        'root' => public_path('uploads'),
        'url' => env('APP_URL').'/uploads',
        'visibility' => 'public',
    ],
    
  • Set APP_URL in .env file to match the server URL

7. Manage and Display Data

  • Refresh Admin Panel to see and manage student data
  • Modify column display in StudentController.php to show images
    $grid->column('image')->display(function ($image) {
        return "<img src='/uploads/{$image}' width='50'/>";
    });
    

8. Create Controllers for Existing Tables

  • Use Scaffold for existing tables (e.g., users)
    • Create only controller and menu (skip migration)

Conclusion

  • Successfully installed and configured an Admin Panel using Laravel.
  • Encouraged to ask questions or request specific tutorials in the comments.
  • Invite to subscribe for more tutorials.