mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-31 18:34:10 +00:00
Admin Workflow - Fix Reported Issues - More filtering user controls for admin to find issues
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Questionnaires\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Questionnaires\Services\ListsQuestions;
|
||||
use App\Classes\Modules\Questionnaires\Standards\Rules\CanListQuestions;
|
||||
use App\Http\Resources\QuestionResource;
|
||||
use App\Models\QAQuestionnaireSet;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ListQuestionsLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Retrieved Questions',
|
||||
'message' => 'You have successfully retrieved a list of questions'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanListQuestions */
|
||||
private $canListQuestions;
|
||||
|
||||
/** @var ListsQuestions */
|
||||
private $listsQuestions;
|
||||
|
||||
/**
|
||||
* ListQuestionsLogic constructor.
|
||||
* @param CanListQuestions $canListQuestions
|
||||
* @param ListsQuestions $listsQuestions
|
||||
*/
|
||||
public function __construct(CanListQuestions $canListQuestions, ListsQuestions $listsQuestions)
|
||||
{
|
||||
$this->canListQuestions = $canListQuestions;
|
||||
$this->listsQuestions = $listsQuestions;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$this->canListQuestions->passes();
|
||||
$setId = 0;
|
||||
if ($request->route('set_id')) {
|
||||
$setId = $request->route('set_id');
|
||||
}
|
||||
|
||||
if($setId === 0){
|
||||
$set = QAQuestionnaireSet::where('group', '1688,approve_po,fill_po')->latest('id')->first();
|
||||
$setId = $set->id;
|
||||
}
|
||||
|
||||
$query = $this->listsQuestions->execute(array_merge($this->listsQuestions->deserializeFilters($request->input('filters')), ['questionnaire_set_id' => $setId]));
|
||||
|
||||
return $this->collectionResponse(QuestionResource::collection($query));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user