backend/app/controllers/UserController.php
2024-07-08 16:20:25 +03:00

43 lines
1023 B
PHP

<?php
namespace app\controllers;
use app\helpers\Debug;
use app\models\Question;
use app\models\User;
use http\Encoding\Stream\Debrotli;
use Illuminate\Contracts\View\View;
use Illuminate\Support\Facades\DB;
class UserController {
public function actionCreate(): void
{
Debug::dd("create");
//return User::create(['username'=>$username,'email'=>$email,'password'=>$password]);
}
public function actionQuestionCount($user_id)
{
return Question::where('user_id', $user_id)->count();
}
public function actionIndex(): void
{
Debug::dd("list");
foreach (User::all() as $user)
{
echo $user->username . "<br>";
}
}
public function actionView($id): void
{
Debug::dd($id);
echo User::where('id', '=', $id)->get();
// $user = User::where('id', '=', 13)->get();
// echo $user->username . "<br>";
// echo $user->email . "<br>";
// echo $user->created_at . "<br>";
}
}