MicroFrameWork/app/controllers/Users.php
2024-07-05 13:49:04 +03:00

38 lines
907 B
PHP

<?php
namespace app\controllers;
use app\models\Question;
use app\models\User;
use Illuminate\Contracts\View\View;
use Illuminate\Support\Facades\DB;
class Users {
public function actionCreateUser($username, $email, $password)
{
return User::create(['username'=>$username,'email'=>$email,'password'=>$password]);
}
public function actionQuestionCount($user_id)
{
return Question::where('user_id', $user_id)->count();
}
public function actionViewAllUsers(): void
{
foreach (User::all() as $user)
{
echo $user->username . "<br>";
}
}
public function actionViewUser(): void
{
echo User::where('id', '=', 13)->get();
// $user = User::where('id', '=', 13)->get();
// echo $user->username . "<br>";
// echo $user->email . "<br>";
// echo $user->created_at . "<br>";
}
}