# eTailorz admin panel — setup steps

## 1. Add the `admin` guard
In `config/auth.php`, inside `'guards' => [...]`, add:

```php
'admin' => [
    'driver' => 'session',
    'provider' => 'users',
],
```

## 2. Register the middleware
Laravel 11 (`bootstrap/app.php`):
```php
->withMiddleware(function (Middleware $middleware) {
    $middleware->alias([
        'role' => \App\Http\Middleware\CheckRole::class,
        'permission' => \App\Http\Middleware\CheckPermission::class,
    ]);
})
```

Laravel 10 (`app/Http/Kernel.php`), inside `$middlewareAliases`:
```php
'role' => \App\Http\Middleware\CheckRole::class,
'permission' => \App\Http\Middleware\CheckPermission::class,
```

## 3. Update the User model
`app/Models/User.php` — add to `$fillable`:
```php
protected $fillable = ['name', 'email', 'password', 'type_id', 'shop_id', 'is_active'];

public function shop()
{
    return $this->belongsTo(Shop::class);
}
```

## 4. Run migration + seeder
```bash
php artisan migrate
php artisan db:seed --class=AdminUserSeeder
php artisan db:seed --class=PermissionSeeder
php artisan db:seed --class=GarmentTypeSeeder
php artisan db:seed --class=MeasurementFieldSeeder
```
> Note: the migration adds a `shop_id` foreign key to `shops`. Run it only after
> your `shops` table migration, or drop the `->constrained()` line temporarily.

## 4b. Add role support to your User model
Open `USER_MODEL_ADDITIONS.txt` and copy those changes into your existing
`app/Models/User.php` — adds the `role()` relationship and `hasPermission()` check.

## 5. Test logins (from AdminUserSeeder)
| Role | Email | Password |
|---|---|---|
| Super Admin | superadmin@etailorz.com | password123 |
| Shop Owner | owner@maduraishop.com | password123 |
| Staff | staff@maduraishop.com | password123 |

**Change these passwords before going to production.**

## 6. File map
```
app/Http/Controllers/Auth/LoginController.php
app/Http/Controllers/Admin/DashboardController.php
app/Http/Middleware/CheckRole.php
database/migrations/2026_07_18_000001_add_admin_fields_to_users_table.php
database/seeders/AdminUserSeeder.php
resources/views/layouts/admin.blade.php
resources/views/partials/sidebar.blade.php
resources/views/auth/login.blade.php
resources/views/admin/dashboard.blade.php
routes/web.php   (merge into your existing routes/web.php, don't overwrite)
```
