MicroFrameWork/app/controllers/Answers.php

22 lines
611 B
PHP
Raw Normal View History

2024-07-03 14:41:15 +03:00
<?php
namespace Controllers;
use Models\Answer;
use Models\Upvote;
class Answers {
public static function add_answer($answer,$question_id,$user_id)
{
return Answer::create(['answer'=>$answer,'question_id'=>$question_id,'user_id'=>$user_id]);
}
public static function upvote_answer($answer_id,$user_id)
{
return Upvote::create(['answer_id'=>$answer_id,'user_id'=>$user_id]);
}
public static function update_answer($answer_id,$new_answer)
{
$answer = Answer::find($answer_id);
$answer->answer = $new_answer;
return $answer->save();
}
}