diff --git a/app/controllers/QuestionController.php b/app/controllers/QuestionController.php
index 4695860..348ab34 100644
--- a/app/controllers/QuestionController.php
+++ b/app/controllers/QuestionController.php
@@ -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()
diff --git a/app/controllers/UserController.php b/app/controllers/UserController.php
index 0b63046..d74832d 100644
--- a/app/controllers/UserController.php
+++ b/app/controllers/UserController.php
@@ -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 . "
";
echo $user->username . "
";
echo $user->email . "
";
- echo $user->password . "
";
echo $user->created_at . "
";
echo $user->updated_at . "
";
}
diff --git a/app/models/Answer.php b/app/models/Answer.php
index 3b87c46..593e156 100644
--- a/app/models/Answer.php
+++ b/app/models/Answer.php
@@ -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()
diff --git a/app/models/Post.php b/app/models/Post.php
index befd4e9..c223faa 100644
--- a/app/models/Post.php
+++ b/app/models/Post.php
@@ -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'];
}
\ No newline at end of file
diff --git a/app/models/Question.php b/app/models/Question.php
index 8b2361d..ef5d034 100644
--- a/app/models/Question.php
+++ b/app/models/Question.php
@@ -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()
diff --git a/app/models/Upvote.php b/app/models/Upvote.php
deleted file mode 100644
index 865cc61..0000000
--- a/app/models/Upvote.php
+++ /dev/null
@@ -1,10 +0,0 @@
-
+ Вопрос:
+
+
+
+
+
\ No newline at end of file
diff --git a/app/views/userCreate.php b/app/views/userCreate.php
index ca97968..1871424 100644
--- a/app/views/userCreate.php
+++ b/app/views/userCreate.php
@@ -6,7 +6,7 @@
Пароль:
Email адрес:
diff --git a/index.php b/index.php
index afed8b5..49ba953 100644
--- a/index.php
+++ b/index.php
@@ -28,6 +28,15 @@ $router->group(["prefix" => "admin"], function (RouteCollector $router){
$router->post("/", [\app\controllers\UserController::class, 'actionAdd']);
$router->post("/edit", [\app\controllers\UserController::class, 'actionEdit']);
});
+ $router->group(["prefix" => "question"], function (RouteCollector $router){
+ $router->get('/create', [QuestionController::class, 'actionCreate']);
+ $router->get('/update', [QuestionController::class, 'actionUpdate']);
+ $router->get('/delete/{id}', [QuestionController::class, 'actionDelete']);
+ $router->get('/', [QuestionController::class, 'actionIndex']);
+ $router->get('/{id}', [QuestionController::class, 'actionView']);
+ $router->post("/", [QuestionController::class, 'actionAdd']);
+ $router->post("/edit", [QuestionController::class, 'actionEdit']);
+ });
$router->group(["prefix" => "post"], function (RouteCollector $router){
$router->get('/', [\app\controllers\PostController::class, 'actionIndex']);
});
diff --git a/m.php b/m.php
index 07ec700..e3bca0e 100644
--- a/m.php
+++ b/m.php
@@ -1,8 +1,14 @@
create('answer', function (Blueprint $table) {
+ $table->increments('id');
+ $table->string('answer', 255)->nullable(false);
+ $table->integer('user_id');
+ $table->integer('question_id');
+ $table->timestamps();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public static function down(): void
+ {
+ Manager::schema()->dropIfExists('user');
+ }
+}
\ No newline at end of file
diff --git a/migrations/PostMigration.php b/migrations/PostMigration.php
new file mode 100644
index 0000000..f5e6327
--- /dev/null
+++ b/migrations/PostMigration.php
@@ -0,0 +1,36 @@
+create('post', function (Blueprint $table) {
+ $table->increments('id');
+ $table->string('post', 255)->nullable(false);
+ $table->integer('user_id');
+ $table->timestamps();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public static function down(): void
+ {
+ Manager::schema()->dropIfExists('user');
+ }
+}
\ No newline at end of file
diff --git a/migrations/QuestionMigration.php b/migrations/QuestionMigration.php
new file mode 100644
index 0000000..1106ba9
--- /dev/null
+++ b/migrations/QuestionMigration.php
@@ -0,0 +1,36 @@
+create('question', function (Blueprint $table) {
+ $table->increments('id');
+ $table->string('question', 255)->nullable(false);
+ $table->integer('user_id');
+ $table->timestamps();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public static function down(): void
+ {
+ Manager::schema()->dropIfExists('user');
+ }
+}
\ No newline at end of file