# Phase 14: Role-Based Dashboards & Demo Accounts

## Date
- 2026-04-16

## Scope
- Unified `/dashboard` behavior across `student`, `instructor`, and `admin` users.
- Added persistent `user_type` support alongside the existing Spatie role system.
- Added live-test demo accounts through a database seeder.

## What Was Implemented
1. `users.user_type`
   - Added a new `user_type` column to the `users` table.
   - Existing users are backfilled from assigned Spatie roles where possible.
   - New student registrations and Google sign-ins now persist `user_type = student`.
2. Unified dashboard entrypoint
   - `/dashboard` now routes to a dedicated `DashboardController`.
   - The controller inspects `user_type` and returns a role-specific dashboard view.
3. Role-specific dashboard surfaces
   - `student`: course progress, active enrollments, learning summary, account snapshot.
   - `instructor`: authored course stats, publishing pipeline summary, recent enrollments, quick links.
   - `admin`: user/revenue/platform metrics, recent users, recent payments, quick links.
4. Shared dashboard shell
   - Introduced a shared dashboard layout with a consistent sidebar, header, and logout actions.
   - Navigation items now change by role.
   - Added a header role card beside the logout action that shows `Login As Student`, `Login As Instructor`, or `Login As Admin` based on the signed-in account.
5. Demo test accounts
   - Added `DemoAccountSeeder` with:
     - `student@cepi.pk`
     - `intructor@cepi.pk`
   - Seeder is idempotent and syncs the correct role plus `user_type`.

## Files Added
- `app/Http/Controllers/DashboardController.php`
- `database/migrations/2026_04_16_120000_add_user_type_to_users_table.php`
- `database/seeders/DemoAccountSeeder.php`
- `resources/views/dashboard/layout.blade.php`
- `resources/views/dashboard/student.blade.php`
- `resources/views/dashboard/instructor.blade.php`
- `resources/views/dashboard/admin.blade.php`

## Files Updated
- `routes/web.php`
- `app/Models/User.php`
- `app/Http/Controllers/Auth/RegisteredUserController.php`
- `app/Http/Controllers/Auth/SocialAuthController.php`
- `database/seeders/DatabaseSeeder.php`
- `database/seeders/RoleSeeder.php`

## Seeder Notes
- Demo accounts are created with the default password:
  - `Password@123`
- The instructor email was created exactly as requested:
  - `intructor@cepi.pk`

## Assumptions
- `user_type` complements the role system rather than replacing middleware-based authorization.
- Existing admin and instructor route groups remain valid and unchanged; the new dashboard behavior only improves the shared `/dashboard` landing experience.
