Files
exchange-2.0/app/Classes/Modules/Questionnaires/Processors/FetchFirstQuestionV1AdminWFProcessor.php
T
2024-12-02 23:06:44 +08:00

40 lines
1.1 KiB
PHP

<?php
namespace App\Classes\Modules\Questionnaires\Processors;
use App\Classes\Modules\Questionnaires\Services\FetchesQuestion;
use App\Models\QAQuestionnaireSet;
use ErrorException;
use Illuminate\Http\Request;
class FetchFirstQuestionV1AdminWFProcessor
{
/** @var FetchesQuestion */
private $fetchesQuestion;
/**
* FetchFirstQuestionV1AdminWFProcessor constructor.
* @param FetchesQuestion $fetchesQuestion
*/
public function __construct(FetchesQuestion $fetchesQuestion)
{
$this->fetchesQuestion = $fetchesQuestion;
}
public function execute(Request $request){
try {
$setId = $request->route('set_id');
if($setId === '0'){
$set = QAQuestionnaireSet::where('group', 'workflow')->latest('id')->first();
$setId = $set->id;
}
$query = $this->fetchesQuestion->execute(['questionnaire_set_id' => $setId]);
return $query;
} catch (\Exception $exception){
throw new ErrorException($exception->getMessage(), $exception->getCode());
}
}
}