<?php

namespace App\Modules\Rides\Controllers;

use Core\Controller\Controller;
use App\Modules\Rides\Services\RideService;

class RideController extends Controller
{
    private RideService $service;

    public function __construct()
    {
        $this->service = new RideService();
    }

    public function index()
    {
        $rides = $this->service->getAllRides();

        $this->view('rides/index', [
            'rides' => $rides
        ]);
    }
    public function showDriver($id)
    {
        $driver = $this->service->getDriverById((int) $id);

        if (!$driver) {
            exit('Driver not found');
        }

        $this->view('rides/driver', [
            'driver' => $driver
        ]);
    }
}