DNSBlock
This commit is contained in:
32
app/Utils/View.php
Normal file
32
app/Utils/View.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Utils;
|
||||
|
||||
class View
|
||||
{
|
||||
public static function render($view, $data = [])
|
||||
{
|
||||
extract($data);
|
||||
$viewPath = __DIR__ . '/../../resources/views/' . str_replace('.', '/', $view) . '.php';
|
||||
|
||||
if (file_exists($viewPath)) {
|
||||
require $viewPath;
|
||||
} else {
|
||||
echo "View not found: $view";
|
||||
}
|
||||
}
|
||||
|
||||
public static function redirect($url)
|
||||
{
|
||||
header("Location: $url");
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function json($data, $status = 200)
|
||||
{
|
||||
http_response_code($status);
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode($data);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user