migration up

This commit is contained in:
2024-07-10 14:39:37 +03:00
parent 70b2f7e5cc
commit 3df81597b6
14 changed files with 143 additions and 24 deletions

View File

@ -4,9 +4,9 @@ namespace app\controllers;
use app\models\Question;
class QuestionController{
public function actionCreateQuestion($question,$user_id)
public function actionCreate()
{
return Question::create(['question'=>$question,'user_id'=>$user_id]);
require "app/views/questionCreate.php";
}
public function actionGetQuestionsWithAnswers()

View File

@ -5,10 +5,6 @@ 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;
use Illuminate\Database\Eloquent\SoftDeletes;
class UserController {
public function actionCreate(): void
@ -18,6 +14,7 @@ class UserController {
public function actionAdd(): void
{
$_REQUEST["password_hash"] = password_hash($_REQUEST["password_hash"], PASSWORD_DEFAULT);
User::create($_REQUEST);
}
@ -43,7 +40,6 @@ class UserController {
echo $user->id . "<br>";
echo $user->username . "<br>";
echo $user->email . "<br>";
echo $user->password . "<br>";
echo $user->created_at . "<br>";
echo $user->updated_at . "<br>";
}

View File

@ -4,7 +4,7 @@ namespace app\models;
use \Illuminate\Database\Eloquent\Model;
class Answer extends Model {
protected $table = 'AnswerController';
protected $table = 'answer';
protected $fillable = ['answer','user_id','question_id'];
public function upvotes()

View File

@ -4,6 +4,6 @@ namespace app\models;
use \Illuminate\Database\Eloquent\Model;
class Post extends Model
{
protected $table = 'Posts';
protected $table = 'post';
protected $fillable = ['post', 'user_id'];
}

View File

@ -4,7 +4,7 @@ namespace app\models;
use \Illuminate\Database\Eloquent\Model;
class Question extends Model {
protected $table = 'Questions';
protected $table = 'question';
protected $fillable = ['question','user_id'];
public function answers()

View File

@ -1,10 +0,0 @@
<?php
namespace app\models;
use \Illuminate\Database\Eloquent\Model;
class Upvote extends Model {
protected $table = 'Upvotes';
protected $fillable = ['answer_id', 'user_id'];
}

View File

@ -1,9 +1,9 @@
<?php
namespace app\models;
use \Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Model;
class User extends Model {
protected $table = 'user';
protected $fillable = ['username', 'email', 'role'];
protected $fillable = ['username', 'email', 'password_hash', 'role'];
protected $dates = ['deleted at'];
}

View File

@ -0,0 +1,9 @@
<form action="/admin/question" method="post">
Вопрос: <br>
<label>
<textarea name = "question" rows="10" cols="50" placeholder="Введите здесь ваш вопрос"></textarea>
</label> <br> <br>
<input type = "submit" value="Подтвердить">
<input type="reset">
</form>

View File

@ -6,7 +6,7 @@
Пароль:<br>
<label>
<input type = "text" name = "password" required size="50" placeholder="Пароль">
<input type = "text" name = "password_hash" required size="50" placeholder="Пароль">
</label> <br> <br>
Email адрес: <br>