update beta
This commit is contained in:
@ -8,6 +8,7 @@ use app\models\forms\CreateUserForm;
|
||||
use app\models\Question;
|
||||
use app\models\User;
|
||||
use app\services\UserService;
|
||||
use app\tables\columns\UserEditActionColumn;
|
||||
use app\tables\columns\UserViewActionColumn;
|
||||
use Exception;
|
||||
use http\Message;
|
||||
@ -29,11 +30,19 @@ class UserController extends Controller{
|
||||
$userForm = new CreateUserForm();
|
||||
$userService = new UserService();
|
||||
$userForm->load($_REQUEST);
|
||||
// Debug::prn($userForm->validate());
|
||||
// Debug::dd($userForm->getErrors());
|
||||
if ($userForm->validate()){
|
||||
// Debug::prn($userService);
|
||||
|
||||
$userService->create($userForm);
|
||||
$this->redirect("/admin/user");
|
||||
// Debug::dd($userService->create($userForm));
|
||||
$this->redirect("/admin/user/" . User::latest()->first()['id']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->redirect("/admin/user/create");
|
||||
}
|
||||
$this->redirect("/admin/user/create");
|
||||
}
|
||||
|
||||
public function actionQuestionCount($user_id)
|
||||
@ -57,6 +66,7 @@ class UserController extends Controller{
|
||||
]);
|
||||
$table = new ListJsonTable($dataProvider->getJson());
|
||||
$table->addAction(UserViewActionColumn::class);
|
||||
$table->addAction(UserEditActionColumn::class);
|
||||
$table->create();
|
||||
$table->render();
|
||||
}));
|
||||
@ -87,22 +97,40 @@ class UserController extends Controller{
|
||||
echo $this->twig->render('user_table.html.twig');
|
||||
}
|
||||
|
||||
public function actionUpdate(): void
|
||||
public function actionUpdate($id): void
|
||||
{
|
||||
// $loader = new \Twig\Loader\FilesystemLoader(__DIR__.'/../views');
|
||||
// $twig = new \Twig\Environment($loader, ['cache' => 'app/views/cache']);
|
||||
echo $this->twig->render('user_update.html.twig');
|
||||
}
|
||||
|
||||
public function actionEdit(): void
|
||||
public function actionEdit($id): void
|
||||
{
|
||||
$_REQUEST["password_hash"] = password_hash($_REQUEST["password_hash"], PASSWORD_DEFAULT);
|
||||
// $_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_hash = $_REQUEST['password_hash'];
|
||||
// $user->save();
|
||||
|
||||
$user = User::find($_REQUEST['id']);
|
||||
$user->username = $_REQUEST['username'];
|
||||
$user->email = $_REQUEST['email'];
|
||||
$user->password_hash = $_REQUEST['password_hash'];
|
||||
$user->save();
|
||||
// $user = User::find($id);
|
||||
// if (!$user){
|
||||
// throw new Exception(message: "The user not found");
|
||||
// }
|
||||
// $userForm = new CreateUserForm();
|
||||
// $userService = new UserService();
|
||||
// $userForm->load($_REQUEST);
|
||||
//// Debug::prn($userForm->validate());
|
||||
//// Debug::dd($userForm->getErrors());
|
||||
// if ($userForm->validate()){
|
||||
//// Debug::prn($userService);
|
||||
//
|
||||
// $userService->create($userForm);
|
||||
// $this->redirect("/admin/user/" . User::find($id)['id']);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// $this->redirect("/admin/user/update/" . $id);
|
||||
// }
|
||||
}
|
||||
|
||||
public function actionDelete($id): void
|
||||
|
Reference in New Issue
Block a user