PHP code example of nasirkhan / laravel-admin

1. Go to this page and download the library: Download nasirkhan/laravel-admin library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

nasirkhan / laravel-admin example snippets


return [
    // Brand name shown in the sidebar and browser tab
    'name' => env('APP_NAME', 'Admin'),

    // Optional logo path relative to public/ (null = text brand)
    'logo' => null,

    // Default theme: 'system' | 'light' | 'dark'
    'theme' => 'system',

    // Fallback navigation when no dynamic menu (module-manager) is available
    'nav' => [
        [
            'label'    => 'Dashboard',
            'route'    => 'backend.dashboard',
            'icon'     => 'home',
            'children' => [],
        ],
        [
            'label'    => 'Users',
            'route'    => 'backend.users.index',
            'icon'     => 'users',
            'children' => [],
        ],
        [
            'label'    => 'Roles',
            'route'    => 'backend.roles.index',
            'icon'     => 'shield',
            'children' => [],
        ],
        [
            'label'    => 'Notifications',
            'route'    => 'backend.notifications.index',
            'icon'     => 'bell',
            'children' => [],
        ],
    ],
];

protected $fillable = ['name', 'email', 'phone', ...];

// In your AppServiceProvider::boot()
\Livewire\Livewire::component('backend.users-index', \App\Livewire\Admin\UsersIndex::class);

// app/Livewire/Admin/AdminDashboard.php
namespace App\Livewire\Admin;

use Nasirkhan\Admin\Livewire\AdminDashboard as BaseAdminDashboard;

class AdminDashboard extends BaseAdminDashboard
{
    public int $commentsCount;

    public function mount(): void
    {
        parent::mount(); // keeps the existing counts

        $this->commentsCount = \App\Models\Comment::count();
    }
}

// app/Providers/AppServiceProvider.php
use Livewire\Livewire;

public function boot(): void
{
    Livewire::component('admin.dashboard', \App\Livewire\Admin\AdminDashboard::class);
}
bash
php artisan vendor:publish --tag=admin-config
bash
php artisan vendor:publish --tag=admin-views
bash
php artisan vendor:publish --tag=admin-views

resources/views/vendor/admin/
├── users/
│   ├── index.blade.php
│   ├── create.blade.php
│   ├── edit.blade.php
│   ├── show.blade.php
│   ├── changePassword.blade.php
│   └── trash.blade.php
├── roles/
│   ├── index.blade.php
│   ├── create.blade.php
│   ├── edit.blade.php
│   └── show.blade.php
├── notifications/
│   ├── index.blade.php
│   └── show.blade.php
├── 
bash
php artisan vendor:publish --provider="Nasirkhan\Admin\AdminServiceProvider"
bash
php artisan make:migration add_phone_to_users_table --table=users
php artisan migrate
bash
php artisan vendor:publish --tag=admin-views
bash
php artisan vendor:publish --tag=admin-views