mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-23 06:24:03 +00:00
66 lines
1.9 KiB
PHP
66 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace App\Classes\Modules\Exports\ControllersLogic;
|
|
|
|
|
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|
use App\Classes\Modules\Exports\Services\ExportsQuestionsAnswers;
|
|
use App\Classes\Modules\Exports\Standards\Rules\CanExportQuestionsAnswers;
|
|
use Illuminate\Http\Request;
|
|
use App\Classes\General\AWSS3Helper;
|
|
use App\Classes\General\Helper;
|
|
use Illuminate\Support\Facades\Storage;
|
|
use Illuminate\Http\JsonResponse;
|
|
|
|
|
|
class ExportQuestionsAnswersLogic extends AbstractControllerLogic
|
|
{
|
|
/**
|
|
* @return array
|
|
*/
|
|
protected function notification():array {
|
|
return [
|
|
'title' => 'Export Questions & Answers',
|
|
'message' => 'You have successfully exported data'
|
|
];
|
|
}
|
|
|
|
/** @var ExportsQuestionsAnswers */
|
|
private $exportsQuestionsAnswers;
|
|
|
|
/** @var CanExportQuestionsAnswers */
|
|
private $canExport;
|
|
|
|
/**
|
|
* ExportFeedbackDataLogic constructor.
|
|
* @param ExportsQuestionsAnswers $exportsQuestionsAnswers
|
|
* @param CanExportQuestionsAnswers $canExport
|
|
*/
|
|
public function __construct(ExportsQuestionsAnswers $exportsQuestionsAnswers, CanExportQuestionsAnswers $canExport)
|
|
{
|
|
$this->exportsQuestionsAnswers = $exportsQuestionsAnswers;
|
|
$this->canExport = $canExport;
|
|
}
|
|
|
|
|
|
/**
|
|
* @param Request $request
|
|
* @return Response
|
|
*/
|
|
public function logic(Request $request) : JsonResponse
|
|
{
|
|
$this->canExport->passes();
|
|
|
|
$this->exportsQuestionsAnswers->setFilters(Helper::deserializeFilters($request->input('filters')));
|
|
|
|
$exportFileName = 'qas.xls';
|
|
$filesystemDriver = Storage::getDefaultDriver();
|
|
if($filesystemDriver === 's3'){
|
|
return $this->response([ 'src' => AWSS3Helper::S3Exportable($exportFileName, $this->exportsQuestionsAnswers) ]);
|
|
}
|
|
|
|
return $this->response([ 'src' => null ]);
|
|
}
|
|
|
|
}
|