# TrueTrucker - Quick Reference Guide

## Files Created/Updated This Session

### Configuration
- ✅ `/config/theme.php` - Theme colors & settings

### Styling  
- ✅ `/resources/css/theme.css` - All brand colors & components

### Views
- ✅ `/resources/views/layouts/guest.blade.php` - Blue gradient auth layout
- ✅ `/resources/views/layouts/themed-app.blade.php` - Sidebar app layout
- ✅ `/resources/views/auth/register.blade.php` - Branded signup
- ✅ `/resources/views/auth/login.blade.php` - Branded login
- ✅ `/resources/views/dashboard.blade.php` - Owner dashboard
- ✅ `/resources/views/companies/create.blade.php` - Company setup form

### Controllers
- ✅ `/app/Http/Controllers/CompanyController.php` - Company management

### Documentation
- ✅ `/IMPLEMENTATION_GUIDE.md` - Full architecture & workflow guide
- ✅ `/COMPLETION_STATUS.md` - Detailed checklist & next steps

---

## How to Add Trucks Page

### Step 1: Create Controller
```bash
php artisan make:controller TruckController --resource
```

### Step 2: Add to Controller
```php
<?php
namespace App\Http\Controllers;

use App\Models\Truck;
use Illuminate\Http\Request;

class TruckController extends Controller {
    public function index() {
        $trucks = auth()->user()->company->trucks()->paginate(10);
        return view('trucks.index', compact('trucks'));
    }

    public function create() {
        return view('trucks.create');
    }

    public function store(Request $request) {
        $validated = $request->validate([
            'truck_number' => 'required|string|max:10',
            'type' => 'required|in:reefer,dry_van,flatbed,tanker',
            'fuel_cost_per_mile' => 'required|numeric|min:0.1|max:10',
        ]);

        auth()->user()->company->trucks()->create($validated);
        return redirect()->route('owner.trucks.index')->with('success', 'Truck added!');
    }

    public function edit(Truck $truck) {
        return view('trucks.edit', compact('truck'));
    }

    public function update(Request $request, Truck $truck) {
        $validated = $request->validate([
            'truck_number' => 'required',
            'type' => 'required',
            'fuel_cost_per_mile' => 'required|numeric',
        ]);

        $truck->update($validated);
        return redirect()->route('owner.trucks.index')->with('success', 'Truck updated!');
    }

    public function destroy(Truck $truck) {
        $truck->delete();
        return redirect()->route('owner.trucks.index')->with('success', 'Truck deleted!');
    }
}
```

### Step 3: Update Routes
In `/routes/web.php`, the route should already exist:
```php
Route::resource('/trucks', TruckController::class)->names('trucks');
```

### Step 4: Create Views

**trucks/index.blade.php**:
```blade
<x-layouts.themed-app>
    <x-slot:title>Fleet Management</x-slot:title>
    <x-slot:subtitle>Manage your trucks</x-slot:subtitle>

    <div style="margin-bottom: 1.5rem;">
        <a href="{{ route('owner.trucks.create') }}" style="background: #003D7A; color: white; padding: 0.75rem 1.5rem; border-radius: 0.75rem; text-decoration: none; font-weight: 600;">
            + Add Truck
        </a>
    </div>

    <div style="background: white; border: 1px solid #E5E7EB; border-radius: 0.75rem; overflow: hidden;">
        <table style="width: 100%; border-collapse: collapse;">
            <thead>
                <tr style="background: #F9FAFB; border-bottom: 1px solid #E5E7EB;">
                    <th style="padding: 1rem 1.5rem; text-align: left; font-weight: 600; color: #6B7280;">Truck #</th>
                    <th style="padding: 1rem 1.5rem; text-align: left; font-weight: 600; color: #6B7280;">Type</th>
                    <th style="padding: 1rem 1.5rem; text-align: left; font-weight: 600; color: #6B7280;">Fuel Cost/Mile</th>
                    <th style="padding: 1rem 1.5rem; text-align: left; font-weight: 600; color: #6B7280;">Actions</th>
                </tr>
            </thead>
            <tbody>
                @forelse($trucks as $truck)
                    <tr style="border-bottom: 1px solid #E5E7EB;">
                        <td style="padding: 1rem 1.5rem; font-weight: 600; color: #003D7A;">{{ $truck->truck_number }}</td>
                        <td style="padding: 1rem 1.5rem;">{{ ucfirst(str_replace('_', ' ', $truck->type)) }}</td>
                        <td style="padding: 1rem 1.5rem;">${{ number_format($truck->fuel_cost_per_mile, 2) }}</td>
                        <td style="padding: 1rem 1.5rem;">
                            <a href="{{ route('owner.trucks.edit', $truck) }}" style="color: #003D7A; text-decoration: none; margin-right: 1rem;">Edit</a>
                            <form action="{{ route('owner.trucks.destroy', $truck) }}" method="POST" style="display: inline;">
                                @csrf
                                @method('DELETE')
                                <button type="submit" style="background: none; border: none; color: #EF4444; cursor: pointer;">Delete</button>
                            </form>
                        </td>
                    </tr>
                @empty
                    <tr>
                        <td colspan="4" style="padding: 2rem; text-align: center; color: #6B7280;">
                            No trucks yet. <a href="{{ route('owner.trucks.create') }}" style="color: #003D7A; font-weight: 600;">Add one now</a>
                        </td>
                    </tr>
                @endforelse
            </tbody>
        </table>
    </div>

    {{ $trucks->links() }}
</x-layouts.themed-app>
```

**trucks/create.blade.php**: Copy structure from `/resources/views/companies/create.blade.php`

---

## Styling Shortcuts

### Primary Button
```html
<button style="background-color: #003D7A; color: white; padding: 0.75rem 1.5rem; border-radius: 0.75rem; border: none; font-weight: 600; cursor: pointer;">
    Button Text
</button>
```

### Alert Success
```html
<div style="background-color: #D1F4E7; border-left: 4px solid #10B981; padding: 1rem; border-radius: 0.75rem;">
    <p style="color: #065F46; margin: 0; font-weight: 600;">✓ Success!</p>
</div>
```

### Card/Section
```html
<div style="background: white; border: 1px solid #E5E7EB; border-radius: 0.75rem; padding: 1.5rem; box-shadow: 0 1px 2px rgba(0,0,0,0.05);">
    Content here
</div>
```

### Grid Layout
```html
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem;">
    <!-- col 1 -->
    <!-- col 2 -->
</div>
```

---

## Routes Already Configured

```
POST   /register                          - Register new user
POST   /login                             - Login
POST   /logout                            - Logout
GET    /dashboard                         - Owner dashboard
POST   /owner/companies                   - Create company
GET    /owner/trucks                      - List trucks
POST   /owner/trucks                      - Create truck
GET    /owner/trucks/{id}/edit            - Edit truck
PUT    /owner/trucks/{id}                 - Update truck
DELETE /owner/trucks/{id}                 - Delete truck
(same pattern for /drivers, /loads)
```

---

## Test the Application

1. Run migrations: `php artisan migrate:fresh`
2. Start server: `php artisan serve`
3. Visit: `http://localhost:8000`
4. Register at `/register`
5. Setup company at `/owner/companies/create`
6. Add trucks at `/owner/trucks`

---

## Theme Customization

To change colors, edit `/config/theme.php`:
```php
'colors' => [
    'primary' => '#003D7A',      // Change primary color
    'accent' => '#00BFA5',       // Change accent color
    // ... more colors
],
```

Then update the CSS variables in `/resources/css/theme.css`:
```css
:root {
    --color-primary: #003D7A;
    --color-accent: #00BFA5;
    /* ... */
}
```

---

## Common Issues & Solutions

### Issue: Sidebar navigation not showing correct active state
**Solution**: Update sidebar nav links with @if(request()->is()) logic

### Issue: Form not submitting
**Solution**: Check CSRF token: `@csrf` in form

### Issue: Database errors
**Solution**: Run `php artisan migrate:fresh` to reset

### Issue: Styles not applying
**Solution**: Run `npm run build` after CSS changes

---

## Next Priority Tasks

1. **Copy CompanyController pattern** for Trucks → Similar validation & flow
2. **Create Truck CRUD views** → Use card/table patterns from dashboard
3. **Add Drivers management** → Same pattern as trucks
4. **Build upload interface** → Accept PDF/images
5. **Add permission middleware** → Restrict access by role

---

## File Locations Quick Map

```
trucker-platform/web/
├── config/
│   └── theme.php .......................... Theme configuration
├── app/Http/Controllers/
│   ├── CompanyController.php .............. Company CRUD
│   ├── TruckController.php ................ Need to create
│   ├── DriverController.php ............... Need to create
│   └── DocumentController.php ............. Need to create
├── resources/
│   ├── css/
│   │   └── theme.css ...................... All brand styles
│   └── views/
│       ├── layouts/
│       │   ├── guest.blade.php ............ Auth layout
│       │   └── themed-app.blade.php ....... App layout
│       ├── auth/
│       │   ├── register.blade.php
│       │   └── login.blade.php
│       ├── companies/
│       │   └── create.blade.php
│       ├── trucks/
│       │   ├── index.blade.php ............ Need to create
│       │   ├── create.blade.php ........... Need to create
│       │   └── edit.blade.php ............. Need to create
│       └── dashboard.blade.php ............ Owner dashboard
└── routes/
    ├── web.php ............................ Main routes
    └── auth.php ........................... Auth routes

Documentation/
├── IMPLEMENTATION_GUIDE.md ................. Full architecture guide
└── COMPLETION_STATUS.md ................... Checklist & next steps
```

---

**Ready to continue?** Start with the Truck CRUD pattern and follow the same structure!
