25 lines
649 B
PHP
25 lines
649 B
PHP
|
<?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();
|
||
|
}
|
||
|
}
|