twig
This commit is contained in:
@ -6,10 +6,12 @@ use app\helpers\Debug;
|
||||
use app\models\Question;
|
||||
use app\models\User;
|
||||
|
||||
class UserController {
|
||||
class UserController extends Controller{
|
||||
public function actionCreate(): void
|
||||
{
|
||||
require "app/views/userCreate.php";
|
||||
// $loader = new \Twig\Loader\FilesystemLoader(__DIR__.'/../views');
|
||||
// $twig = new \Twig\Environment($loader, ['cache' => 'app/views/cache']);
|
||||
echo $this->twig->render('userCreate.html');
|
||||
}
|
||||
|
||||
public function actionAdd(): void
|
||||
@ -25,10 +27,15 @@ class UserController {
|
||||
|
||||
public function actionIndex(): void
|
||||
{
|
||||
// $loader = new \Twig\Loader\FilesystemLoader(__DIR__.'/../views');
|
||||
// $twig = new \Twig\Environment($loader, ['cache' => 'app/views/cache']);
|
||||
|
||||
$i = 0;
|
||||
foreach (User::all() as $user)
|
||||
{
|
||||
echo $user->username . "<br>";
|
||||
$userArr[$i++] = $user;
|
||||
}
|
||||
echo $this->twig->render('userTable.html', ['userArr' => $userArr]);
|
||||
}
|
||||
|
||||
public function actionView($id): void
|
||||
@ -46,16 +53,19 @@ class UserController {
|
||||
|
||||
public function actionUpdate(): void
|
||||
{
|
||||
Debug::prn("Update");
|
||||
require "app/views/userUpdate.php";
|
||||
// $loader = new \Twig\Loader\FilesystemLoader(__DIR__.'/../views');
|
||||
// $twig = new \Twig\Environment($loader, ['cache' => 'app/views/cache']);
|
||||
echo $this->twig->render('userUpdate.html');
|
||||
}
|
||||
|
||||
public function actionEdit(): void
|
||||
{
|
||||
$_REQUEST["password_hash"] = password_hash($_REQUEST["password_hash"], PASSWORD_DEFAULT);
|
||||
|
||||
$user = User::find($_REQUEST['id']);
|
||||
$user->username = $_REQUEST['username'];
|
||||
$user->email = $_REQUEST['email'];
|
||||
$user->password = $_REQUEST['password'];
|
||||
$user->password_hash = $_REQUEST['password_hash'];
|
||||
$user->save();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user