<?php
class Controller {
    public function model($model) {
        require_once '../app/models/' . $model . '.php';
        return new $model();
    }

    
    // public function view($view, $data = []) {
    //     extract($data); // ✅ This makes $contacts and $role available in the view
    //     require_once "../app/views/" . $view . ".php";
    // }
    
    public function view($view, $data = []) {
        extract($data);
    
        $viewPath = "../app/views/$view.php";
        if (file_exists($viewPath)) {
            require "../app/views/layout.php";
        } else {
            echo "View $view not found.";
        }
    }


}
