diff --git a/app/controllers/Answers.php b/app/controllers/Answers.php
index 30b7af0..6ba2100 100644
--- a/app/controllers/Answers.php
+++ b/app/controllers/Answers.php
@@ -1,22 +1,32 @@
$answer,'question_id'=>$question_id,'user_id'=>$user_id]);
}
- public static function upvote_answer($answer_id,$user_id)
+ public static function actionUpvoteAnswer($answer_id,$user_id)
{
return Upvote::create(['answer_id'=>$answer_id,'user_id'=>$user_id]);
}
- public static function update_answer($answer_id,$new_answer)
+ public function actionUpdateAnswer($answer_id,$new_answer)
{
$answer = Answer::find($answer_id);
$answer->answer = $new_answer;
return $answer->save();
}
+
+ public function actionViewAllAnswers(): void
+ {
+ foreach (Answer::all() as $answer)
+ {
+ echo $answer->answer . "
";
+ }
+ }
}
\ No newline at end of file
diff --git a/app/controllers/Posts.php b/app/controllers/Posts.php
index e43cc08..8d92028 100644
--- a/app/controllers/Posts.php
+++ b/app/controllers/Posts.php
@@ -1,13 +1,22 @@
$post, 'user_id'=>$user_id]);
}
+
+ public function actionViewAllPosts()
+ {
+ foreach (Post::all() as $post)
+ {
+ echo $post->post . "
";
+ }
+ }
}
\ No newline at end of file
diff --git a/app/controllers/Questions.php b/app/controllers/Questions.php
index 0b76ddf..c94821f 100644
--- a/app/controllers/Questions.php
+++ b/app/controllers/Questions.php
@@ -1,25 +1,34 @@
$question,'user_id'=>$user_id]);
}
- public static function get_questions_with_answers()
+ public function actionGetQuestionsWithAnswers()
{
return Question::with('Answers')->get()->toArray();
}
- public static function get_questions_with_users()
+ public function actionGetQuestionsWithUsers()
{
return Question::with('user')->get()->toArray();
}
- public static function get_question_answers_upvotes($question_id)
+ public function actionGetQuestionAnswersUpvotes($question_id)
{
return Question::find($question_id)->answers()->with('upvotes')->get()->toArray();
}
+
+ public function actionViewAllQuestions()
+ {
+ foreach (Question::all() as $question)
+ {
+ echo $question->question. "
";
+ }
+ }
}
\ No newline at end of file
diff --git a/app/controllers/Users.php b/app/controllers/Users.php
index c251c47..215f855 100644
--- a/app/controllers/Users.php
+++ b/app/controllers/Users.php
@@ -1,7 +1,11 @@
count();
}
+
+ public function actionViewAllUsers(): void
+ {
+ foreach (User::all() as $user)
+ {
+ echo $user->username . "
";
+ }
+ }
+
+ public function actionViewUser(): void
+ {
+ echo User::where('id', '=', 13)->get();
+// $user = User::where('id', '=', 13)->get();
+
+// echo $user->username . "
";
+// echo $user->email . "
";
+// echo $user->created_at . "
";
+ }
}
\ No newline at end of file
diff --git a/app/views/intro.php b/app/views/intro.php
deleted file mode 100644
index b3d9bbc..0000000
--- a/app/views/intro.php
+++ /dev/null
@@ -1 +0,0 @@
-get('/', [MainController::class, 'actionIndex']);
$router->get('/example', [MainController::class, 'actionExample']);
+//$router->get('/createUser', [Users::class, 'actionCreateUser']);
+$router->get('/allUsers', [Users::class, 'actionViewAllUsers']);
+$router->get('/User', [Users::class, 'actionViewUser'], ['3']);
+$router->get('/allQuestions', [Questions::class, 'actionViewAllQuestions']);
+$router->get('/allPosts', [Posts::class, 'actionViewAllPosts']);
+$router->get('/allAnswers', [Answers::class, 'actionViewAllAnswers']);
+
$dispatcher = new Phroute\Phroute\Dispatcher($router->getData());