v.0.1
This commit is contained in:
25
app/controllers/Questions.php
Normal file
25
app/controllers/Questions.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
namespace Controllers;
|
||||
use Models\Question;
|
||||
|
||||
class Questions{
|
||||
public static function create_question($question,$user_id)
|
||||
{
|
||||
return Question::create(['question'=>$question,'user_id'=>$user_id]);
|
||||
}
|
||||
|
||||
public static function get_questions_with_answers()
|
||||
{
|
||||
return Question::with('Answers')->get()->toArray();
|
||||
}
|
||||
|
||||
public static function get_questions_with_users()
|
||||
{
|
||||
return Question::with('user')->get()->toArray();
|
||||
}
|
||||
|
||||
public static function get_question_answers_upvotes($question_id)
|
||||
{
|
||||
return Question::find($question_id)->answers()->with('upvotes')->get()->toArray();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user