<?php
namespace App\Core;

class Controller
{
    public function model($model)
    {
        $modelClass = "App\\Models\\{$model}";
        if (class_exists($modelClass)) {
            return new $modelClass;
        }
        return null;
    }

    public function view($view, $data = [])
    {
        $viewPath = dirname(__DIR__) . '/Views/' . $view;
        if (file_exists($viewPath)) {
            extract($data);
            require $viewPath;
        } else {
            echo "View {$viewPath} not found.";
        }
    }
}
