MicroFrameWork/app/controllers/Users.php

38 lines
907 B
PHP
Raw Normal View History

2024-07-03 14:41:15 +03:00
<?php
2024-07-05 13:49:04 +03:00
namespace app\controllers;
use app\models\Question;
use app\models\User;
use Illuminate\Contracts\View\View;
use Illuminate\Support\Facades\DB;
2024-07-03 14:41:15 +03:00
class Users {
2024-07-03 15:15:59 +03:00
public function actionCreateUser($username, $email, $password)
2024-07-03 14:41:15 +03:00
{
return User::create(['username'=>$username,'email'=>$email,'password'=>$password]);
}
2024-07-03 15:15:59 +03:00
public function actionQuestionCount($user_id)
2024-07-03 14:41:15 +03:00
{
return Question::where('user_id', $user_id)->count();
}
2024-07-05 13:49:04 +03:00
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>";
}
2024-07-03 14:41:15 +03:00
}