72 lines
1.7 KiB
PHP
72 lines
1.7 KiB
PHP
<?php
|
|
namespace App\Http\Controllers\Admin;
|
|
|
|
use Illuminate\Http\Request;
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\SoulQuestion;
|
|
use App\Models\SoulAnswer;
|
|
class SoulController extends Controller
|
|
{
|
|
//问题列表
|
|
public function questions(Request $request, SoulQuestion $soul_question)
|
|
{
|
|
$questions = $soul_question->with('user')->orderBy('id');
|
|
$is_submit = $request->input('is_submit');
|
|
if (is_numeric($is_submit)) {
|
|
$questions = $questions->where('is_submit', $is_submit);
|
|
}
|
|
$status = $request->input('status', 0);
|
|
if ($status != 2) {
|
|
$questions = $questions->where('status', $status);
|
|
}
|
|
$questions = $questions->paginate();
|
|
return $this->success('ok', $questions);
|
|
}
|
|
|
|
/**
|
|
* 问题详情
|
|
*/
|
|
public function question(Request $request, SoulQuestion $soul_question)
|
|
{
|
|
$soul_question->user;
|
|
$answers = $soul_question->answers();
|
|
$type = $request->input('type');
|
|
if ($type) {
|
|
$answers = $answers->where('type', $type);
|
|
}
|
|
$answers = $answers->with('user')->paginate();
|
|
$soul_question->answers = $answers;
|
|
return $this->success('ok', $soul_question);
|
|
}
|
|
|
|
/**
|
|
* 审核问题
|
|
*/
|
|
public function checkQuestion(Request $request, SoulQuestion $soul_question)
|
|
{
|
|
$status = $request->input('status', 1);
|
|
$soul_question->status = $status;
|
|
$soul_question->save();
|
|
return $this->success('ok');
|
|
}
|
|
|
|
/**
|
|
* 删除问题
|
|
*/
|
|
public function deleteQuestion(Request $request, SoulQuestion $soul_question)
|
|
{
|
|
$soul_question->delete();
|
|
return $this->success('ok');
|
|
}
|
|
|
|
/**
|
|
* 删除答案
|
|
*/
|
|
public function deleteQuestionAnswer(Request $request, SoulAnswer $soul_answer)
|
|
{
|
|
$soul_answer->delete();
|
|
return $this->success('ok');
|
|
}
|
|
|
|
}
|