# Admin Dashboard Setup Guide

## Overview
A complete admin dashboard system has been created for Flat Line to manage users and orders.

## Features

### Admin Dashboard (`/admin/dashboard`)
- Total users count with new users today
- Total orders count with orders today
- Pending orders count
- Total volume exchanged (GHS and CNY)
- Recent orders list (last 15)
- Recent users list (last 10)
- Top users by volume

### Users Management (`/admin/users`)
- View all registered users
- See user details (name, email, wallet balance, total orders, total volume)
- Update user wallet balance
- Pagination support (20 users per page)

### Orders Management (`/admin/orders`)
- View all orders
- See order details (order number, user, amounts, status, date)
- Update order status (pending, processing, completed, cancelled)
- Delete orders
- Pagination support (20 orders per page)

## Admin Credentials

**Email:** admin@flatline.com  
**Password:** admin123

## Test User Credentials

1. **Kwame Mensah**
   - Email: kwame@example.com
   - Password: password
   - Balance: ₵5,000.00

2. **Ama Asante**
   - Email: ama@example.com
   - Password: password
   - Balance: ₵2,500.00

3. **Kofi Owusu**
   - Email: kofi@example.com
   - Password: password
   - Balance: ₵7,500.00

## Access Control

- Admin routes are protected by `auth` and `admin` middleware
- Only users with `is_admin = true` can access admin panel
- Non-admin users get 403 Forbidden error

## Routes

```php
/admin/dashboard          - Admin dashboard overview
/admin/users             - User management
/admin/orders            - Order management
/admin/orders/{id}/status - Update order status (PATCH)
/admin/orders/{id}       - Delete order (DELETE)
/admin/users/{id}/balance - Update user balance (PATCH)
```

## Database Changes

### New Columns
- `users.is_admin` (boolean, default: false)
- `orders.order_number` (string, unique)

### Migrations Created
- `2024_01_04_000000_add_is_admin_to_users_table.php`
- `2026_03_29_164128_add_order_number_to_orders_table.php`

## Seeders

### AdminUserSeeder
Creates admin user and 3 test users with sample data

### OrderSeeder
Creates 3-5 sample orders per user with random amounts and statuses

## Running Seeders

```bash
# Create admin and test users
php artisan db:seed --class=AdminUserSeeder

# Create sample orders
php artisan db:seed --class=OrderSeeder
```

## UI Design

The admin panel uses the same Flat Line design system:
- Dark blue gradient backgrounds
- Glassmorphism effects
- Animated orbs
- Responsive tables
- Modal dialogs for updates
- Status badges with colors
- Pagination controls

## Security Features

1. **Middleware Protection**: All admin routes require authentication and admin role
2. **CSRF Protection**: All forms include CSRF tokens
3. **Role-Based Access**: Only admins can access admin panel
4. **Confirmation Dialogs**: Delete actions require confirmation

## Future Enhancements

- Export data to CSV/Excel
- Advanced filtering and search
- User activity logs
- Email notifications
- Bulk actions
- Analytics charts
- Admin activity audit trail
