Rev 15043 | Autoría | Ultima modificación | Ver Log |
<?php
declare(strict_types=1);
namespace LeadersLinked\Controller;
use Laminas\Db\Adapter\AdapterInterface;
use Laminas\Cache\Storage\Adapter\AbstractAdapter;
use Laminas\Mvc\Controller\AbstractActionController;
use Laminas\Log\LoggerInterface;
use Laminas\View\Model\ViewModel;
use Laminas\View\Model\JsonModel;
use LeadersLinked\Library\Functions;
use LeadersLinked\Mapper\FeedMapper;
use LeadersLinked\Mapper\TopicMapper;
use LeadersLinked\Mapper\FeedTopicMapper;
use LeadersLinked\Mapper\QueryMapper;
use Laminas\Paginator\Adapter\DbSelect;
use Laminas\Paginator\Paginator;
use LeadersLinked\Form\DevelopmentContentCreateFeedForm;
use LeadersLinked\Form\TopicForm;
use Laminas\Hydrator\ArraySerializableHydrator;
use Laminas\Db\ResultSet\HydratingResultSet;
use LeadersLinked\Model\FeedTopic;
use LeadersLinked\Model\Feed;
use LeadersLinked\Model\Topic;
use LeadersLinked\Mapper\CompanyMapper;
use LeadersLinked\Model\Company;
use LeadersLinked\Hydrator\ObjectPropertyHydrator;
class DevelopmentContentController extends AbstractActionController
{
/**
*
* @var AdapterInterface
*/
private $adapter;
/**
*
* @var AbstractAdapter
*/
private $cache;
/**
*
* @var LoggerInterface
*/
private $logger;
/**
*
* @var array
*/
private $config;
/**
*
* @param AdapterInterface $adapter
* @param AbstractAdapter $cache
* @param LoggerInterface $logger
* @param array $config
*/
public function __construct($adapter, $cache, $logger, $config)
{
$this->adapter = $adapter;
$this->cache = $cache;
$this->logger = $logger;
$this->config = $config;
}
public function indexAction()
{
return new JsonModel([
'success' => false,
'data' => 'ERROR_METHOD_NOT_ALLOWED'
]);
}
public function listingAction()
{
$request = $this->getRequest();
$currentUserPlugin = $this->plugin('currentUserPlugin');
$currentCompany = $currentUserPlugin->getCompany();
$currentUser = $currentUserPlugin->getUser();
if ($request->isGet()) {
$headers = $request->getHeaders();
$isJson = false;
if ($headers->has('Accept')) {
$accept = $headers->get('Accept');
$prioritized = $accept->getPrioritized();
foreach ($prioritized as $key => $value) {
$raw = trim($value->getRaw());
if (!$isJson) {
$isJson = strpos($raw, 'json');
}
}
}
if ($isJson) {
$search = $this->params()->fromQuery('search', []);
$search = empty($search['value']) ? '' : filter_var($search['value'], FILTER_SANITIZE_STRING);
$start = intval($this->params()->fromQuery('start', 0), 10);
$records_x_page = intval($this->params()->fromQuery('length', 10), 10);
$page = intval($start / $records_x_page);
$page++;
$acl = $this->getEvent()->getViewModel()->getVariable('acl');
$allowAdd = $acl->isAllowed($currentUser->usertype_id, 'development-and-content/add');
$allowEdit = $acl->isAllowed($currentUser->usertype_id, 'development-and-content/edit');
$allowDelete = $acl->isAllowed($currentUser->usertype_id, 'development-and-content/delete');
$allowAproved = $acl->isAllowed($currentUser->usertype_id, 'development-and-content/aproved');
$items = [];
$feedMapper = FeedMapper::getInstance($this->adapter);
$category_uuid = $this->params()->fromRoute('category_id');
if (!$category_uuid) {
if($allowEdit){
$paginator = $feedMapper->fetchAllByDevelop();
}else{
$paginator = $feedMapper->fetchAllByDevelopContentPublished();
}
}else{
$topicMapper = TopicMapper::getInstance($this->adapter);
$topic = $topicMapper->fetchOneByUuid($category_uuid);
if (!$topic) {
$data = [
'success' => false,
'data' => 'ERROR_RECORD_NOT_FOUND'
];
return new JsonModel($data);
}
if($allowEdit){
$paginator = $feedMapper->fetchAllByDevelopContentByCategoryId($topic->id);
}
$paginator = $feedMapper->fetchAllByDevelopContentPublishedByCategoryId($topic->id);
}
foreach ($paginator as $record) {
$topicMapper = TopicMapper::getInstance($this->adapter);
$topic = $topicMapper->fetchOne($record->topic_id);
$topic_title = ($topic) ? $topic->title : '';
$preview = ($record->file_image_preview != null && $record->file_image_preview != '') ? $this->url()->fromRoute('storage', ['code' => $record->uuid, 'type' => 'feed', 'filename' => $record->file_image_preview]) : '';
$item = [
'uuid' => $record->uuid,
'title' => $record->title,
'topic' => $topic_title,
'added_on' => $record->added_on,
'description' => $record->description,
'file' => $record->file_type ? $record->file_type : '',
'link_media' => $record->link_media ? $record->link_media : '',
'link_name' => $record->link_name,
'file_name' => $record->file_name ? $record->file_name : '',
'link_file' => $this->url()->fromRoute('storage', ['code' => $record->uuid, 'type' => 'feed', 'filename' => $record->file_name]),
'status' => $record->status,
'preview' => $preview,
'actions' => [
'link_edit' => ($allowEdit) ? $this->url()->fromRoute('development-and-content/edit', ['id' => $record->uuid]) : '',
'link_aproved' => ($allowAproved) ? $this->url()->fromRoute('development-and-content/aproved', ['id' => $record->uuid]) : '',
'link_delete' => ($allowDelete) ? $this->url()->fromRoute('development-and-content/delete', ['id' => $record->uuid]) : '',
]
];
array_push($items, $item);
}
return new JsonModel([
'success' => true,
'data' => [
'items' => $items,
]
]);
} else {
$topicMapper = TopicMapper::getInstance($this->adapter);
$result = $topicMapper->fetchAllDevelopment();
$categories=[];
foreach ($result as $record) {
$item = [
'uuid'=>$record->uuid,
'title'=>$record->title,
'filter'=>$this->url()->fromRoute('development-and-content/listing', ['category_id' => $record->uuid]),
];
array_push($categories, $item);
}
$form = new DevelopmentContentCreateFeedForm($this->adapter, $currentCompany->id);
$this->layout()->setTemplate('layout/layout-backend');
$viewModel = new ViewModel();
$viewModel->setTemplate('leaders-linked/development-content/index.phtml');
$viewModel->setVariables([
'form' => $form,
'categories' => $categories,
]);
return $viewModel;
}
} else {
return new JsonModel([
'success' => false,
'data' => 'ERROR_METHOD_NOT_ALLOWED'
]);
}
}
public function addAction()
{
$currentUserPlugin = $this->plugin('currentUserPlugin');
$currentCompany = $currentUserPlugin->getCompany();
$currentUser = $currentUserPlugin->getUser();
$request = $this->getRequest();
if ($request->isPost()) {
$form = new DevelopmentContentCreateFeedForm($this->adapter);
$dataPost = array_merge($request->getPost()->toArray(), $request->getFiles()->toArray());
$form->setData($dataPost);
if ($form->isValid()) {
$dataPost = (array) $form->getData();
$hydrator = new ObjectPropertyHydrator();
$feed = new Feed();
$hydrator->hydrate($dataPost, $feed);
$topicMapper = TopicMapper::getInstance($this->adapter);
$topic = $topicMapper->fetchOneByUuid($dataPost['category_content']);
$feed->user_id = $currentUser->id;
$feed->company_id = $currentCompany->id;
$feed->user_id = $currentUser->id;
$feed->status = Feed::STATUS_SAVED;
$feed->topic_id = $topic->id;
$feed->type = Feed::TYPE_DC;
$feed->posted_or_shared = Feed::POSTED;
$feed->shared_with = Feed::SHARE_WITH_PUBLIC;
$feed->total_comments = 0;
$feed->total_shared = 0;
$filesArray = $this->getRequest()->getFiles()->toArray();
$file_type = '';
$files = null;
if (isset($filesArray['doc']) && empty($filesArray['doc']['error'])) {
$files = $filesArray['doc'];
}
if (isset($filesArray['video']) && empty($filesArray['video']['error'])) {
$files = $filesArray['video'];
}
if (isset($files) && empty($files['error'])) {
$feed_tmp_filename = $files['tmp_name'];
$feed_filename = $this->normalizeString($files['name']);
$mime_type = mime_content_type($feed_tmp_filename);
if ($mime_type == 'image/jpg' || $mime_type == 'image/jpeg' || $mime_type == 'image/png') {
$file_type = Feed::FILE_TYPE_IMAGE;
} else if ($mime_type == 'video/webm' || $mime_type == 'video/mpeg' || $mime_type == 'video/mpg' || $mime_type == 'video/mp4') {
$file_type = Feed::FILE_TYPE_VIDEO;
} else if ($mime_type == 'application/pdf') {
$file_type = Feed::FILE_TYPE_DOCUMENT;
}
}
//preview
$fileImg = $this->params()->fromFiles('image');
if (isset($fileImg) && empty($fileImg['error'])) {
$img_tmp_filename = $fileImg['tmp_name'];
$img_filename = $this->normalizeString($fileImg['name']);
} else {
$img_tmp_filename = null;
$img_filename = null;
}
$feedMapper = FeedMapper::getInstance($this->adapter);
if ($feedMapper->insert($feed)) {
$feed = $feedMapper->fetchOne($feed->id);
$feedMapper->update($feed);
if ($file_type == Feed::FILE_TYPE_DOCUMENT) {
$target_path = $this->config['leaderslinked.fullpath.feed'] . $feed->uuid;
if (!file_exists($target_path)) {
mkdir($target_path, 0755);
}
$full_filename = $target_path . DIRECTORY_SEPARATOR . $feed_filename;
$result = move_uploaded_file($feed_tmp_filename, $full_filename);
if ($result) {
$feed->file_type = $file_type;
$feed->file_name = basename($feed_filename);
$feedMapper->update($feed);
} else {
error_log('no se pudo mover o renombrar el documento : ' . $feed_tmp_filename . ' al directorio : ' . $full_filename);
}
}
if ($file_type == Feed::FILE_TYPE_IMAGE) {
$target_path = $this->config['leaderslinked.fullpath.feed'] . $feed->uuid;
if (!file_exists($target_path)) {
mkdir($target_path, 0755);
}
list($target_width, $target_height) = explode('x', $this->config['leaderslinked.image_sizes.feed_image_size']);
$feed_filename = substr($feed_filename, 0, strrpos($feed_filename, '.')) . '.png';
$crop_to_dimensions = false;
if (Image::uploadImage($feed_tmp_filename, $target_path, $feed_filename, $target_width, $target_height, $crop_to_dimensions)) {
$feed->file_type = $file_type;
$feed->file_name = basename($feed_filename);
$feedMapper->update($feed);
}
}
if ($file_type == Feed::FILE_TYPE_VIDEO) {
$target_path = $this->config['leaderslinked.fullpath.feed'] . $feed->uuid;
if (!file_exists($target_path)) {
mkdir($target_path, 0755);
}
$full_filename = $target_path . DIRECTORY_SEPARATOR . $feed_filename;
$result = move_uploaded_file($feed_tmp_filename, $full_filename);
if ($result) {
$size = $this->config['leaderslinked.image_sizes.feed_image_size'];
$getFromSecound = 2;
//extracción del cover
$generateFileName = substr($feed_filename, 0, strrpos($feed_filename, '.'));
$generateFile = $target_path . DIRECTORY_SEPARATOR . $generateFileName . '.png';
$cmd = "/usr/bin/ffmpeg -i $full_filename -an -ss $getFromSecound -s $size $generateFile";
exec($cmd);
$feed->file_type = $file_type;
$feed->file_name = basename($feed_filename);
$feed->file_image_preview = basename($generateFile);
$feedMapper->update($feed);
$videoConvert = new VideoConvert();
$videoConvert->filename = $full_filename;
$videoConvert->type = VideoConvert::TYPE_FEED;
$videoConvertMapper = VideoConvertMapper::getInstance($this->adapter);
$videoConvertMapper->insert($videoConvert);
} else {
error_log('no se pudo mover o renombrar el documento : ' . $feed_tmp_filename . ' al directorio : ' . $full_filename);
}
}
if ($file_type != Feed::FILE_TYPE_VIDEO && !empty($img_tmp_filename) && !empty($img_filename)) {
$target_path = $this->config['leaderslinked.fullpath.feed'] . $feed->uuid;
if (!file_exists($target_path)) {
mkdir($target_path, 0755);
}
Functions::deleteFilename($target_path, $feed->file_image_preview);
list($target_width, $target_height) = explode('x', $this->config['leaderslinked.image_sizes.feed_image_size']);
$img_filename = substr($img_filename, 0, strrpos($img_filename, '.')) . '.png';
if (Functions::uploadImage($img_tmp_filename, $target_path, $img_filename, $target_width, $target_height)) {
$feed->file_image_preview = basename($img_filename);
$feedMapper->update($feed);
} else {
error_log('no se pudo mover o renombrar el documento : ' . $feed_tmp_filename . ' al directorio : ' . $full_filename);
}
}
$response = [
'success' => true,
'data' => 'success'
];
} else {
$messages = [];
$form_messages = (array) $form->getMessages();
foreach ($form_messages as $fieldname => $field_messages) {
$messages[$fieldname] = array_values($field_messages);
}
}
} else {
$response = [
'success' => false,
'data' => 'ERROR_METHOD_NOT_ALLOWED'
];
}
return new JsonModel($response);
}
}
public function deleteAction()
{
$currentUserPlugin = $this->plugin('currentUserPlugin');
$currentUser = $currentUserPlugin->getUser();
$currentCompany = $currentUserPlugin->getCompany();
$request = $this->getRequest();
if ($request->isPost()) {
$id = $this->params()->fromRoute('id');
$feedMapper = FeedMapper::getInstance($this->adapter);
$feed = $feedMapper->fetchOneByUuid($id);
if (!$feed) {
$response = [
'success' => false,
'data' => 'ERROR_POST_NOT_FOUND'
];
return new JsonModel($response);
}
if ($feed->company_id != $currentCompany->id) {
$response = [
'success' => false,
'data' => 'ERROR_UNAUTHORIZED'
];
return new JsonModel($response);
}
$feedMapper = FeedMapper::getInstance($this->adapter);
$feed->status = Feed::STATUS_DELETED;
if ($feedMapper->update($feed)) {
$response = [
'success' => true,
'data' => 'LABEL_FEED_WAS_DELETED'
];
} else {
$response = [
'success' => false,
'data' => $feedMapper->getError()
];
}
return new JsonModel($response);
} else {
$response = [
'success' => false,
'data' => 'ERROR_METHOD_NOT_ALLOWED'
];
}
return new JsonModel($response);
}
private function normalizeString($str = '')
{
$basename = substr($str, 0, strrpos($str, '.'));
$basename = str_replace('.', '-', $basename);
$extension = substr($str, strrpos($str, '.'));
$str = $basename . $extension;
return Functions::normalizeString($str);
}
public function aprovedAction()
{
$currentUserPlugin = $this->plugin('currentUserPlugin');
$currentUser = $currentUserPlugin->getUser();
$currentCompany = $currentUserPlugin->getCompany();
$request = $this->getRequest();
if ($request->isPost()) {
$id = $this->params()->fromRoute('id');
$feedMapper = FeedMapper::getInstance($this->adapter);
$feed = $feedMapper->fetchOneByUuid($id);
if (!$feed) {
$response = [
'success' => false,
'data' => 'ERROR_POST_NOT_FOUND'
];
return new JsonModel($response);
}
if ($feed->company_id != $currentCompany->id) {
$response = [
'success' => false,
'data' => 'ERROR_UNAUTHORIZED'
];
return new JsonModel($response);
}
$feedMapper = FeedMapper::getInstance($this->adapter);
$feed->status = Feed::STATUS_PUBLISHED;
if ($feedMapper->update($feed)) {
$response = [
'success' => true,
'data' => 'LABEL_FEED_WAS_ADDED'
];
} else {
$response = [
'success' => false,
'data' => $feedMapper->getError()
];
}
return new JsonModel($response);
} else {
$response = [
'success' => false,
'data' => 'ERROR_METHOD_NOT_ALLOWED'
];
}
return new JsonModel($response);
}
public function editAction()
{
$currentUserPlugin = $this->plugin('currentUserPlugin');
$currentCompany = $currentUserPlugin->getCompany();
$currentUser = $currentUserPlugin->getUser();
$request = $this->getRequest();
$uuid = $this->params()->fromRoute('id');
if (!$uuid) {
$data = [
'success' => false,
'data' => 'ERROR_INVALID_PARAMETER'
];
return new JsonModel($data);
}
$feedMapper = FeedMapper::getInstance($this->adapter);
$feed = $feedMapper->fetchOneByUuid($uuid);
if (!$feed) {
$data = [
'success' => false,
'data' => 'ERROR_RECORD_NOT_FOUND'
];
return new JsonModel($data);
}
if ($currentCompany) {
if ($feed->company_id != $currentCompany->id) {
$data = [
'success' => false,
'data' => 'ERROR_UNAUTHORIZED'
];
return new JsonModel($data);
}
} else {
if ($feed->company_id) {
$data = [
'success' => false,
'data' => 'ERROR_UNAUTHORIZED'
];
return new JsonModel($data);
}
}
if($request->isGet()) {
$topicMapper = TopicMapper::getInstance($this->adapter);
$topic = $topicMapper->fetchOne($feed->topic_id);
$preview = ($feed->file_image_preview != null && $feed->file_image_preview != '') ? $this->url()->fromRoute('storage', ['code' => $feed->uuid, 'type' => 'feed', 'filename' => $feed->file_image_preview]) : null;
return new JsonModel([
'success' => true,
'data' => [
'feed' => [
'uuid' => $feed->uuid,
'title' => $feed->title,
'added_on' => $feed->added_on,
'description' => $feed->description,
'file' => $feed->file_type ? $feed->file_type : '',
'link_media' => $feed->link_media ? $feed->link_media : '',
'link_name' => $feed->link_name,
'file_name' => $feed->file_name ? $feed->file_name : '',
'link_file' => ($feed->file_name != null && $feed->file_name != '') ? $this->url()->fromRoute('storage', ['code' => $feed->uuid, 'type' => 'feed', 'filename' => $feed->file_name]) : null,
'status' => $feed->status,
],
'topic' => [
'uuid'=> $topic->uuid
],
'action' => $this->url()->fromRoute('development-and-content/edit', ['id' => $feed->uuid]),
'preview' => $preview
]
]);
} else if ($request->isPost()) {
$form = new DevelopmentContentCreateFeedForm($this->adapter);
$dataPost = array_merge($request->getPost()->toArray(), $request->getFiles()->toArray());
$categoryUuid = $dataPost['category_content'];
$dataPost['category_id'] = null;
$form->setData($dataPost);
if ($form->isValid()) {
$dataPost = (array) $form->getData();
$filesArray = $this->getRequest()->getFiles()->toArray();
$files = null;
if (isset($filesArray['doc']) && empty($filesArray['doc']['error'])) {
$files = $filesArray['doc'];
}
if (isset($filesArray['video']) && empty($filesArray['video']['error'])) {
$files = $filesArray['video'];
}
$file_type = '';
if (isset($files) && empty($files['error'])) {
$feed_tmp_filename = $files['tmp_name'];
$feed_filename = $this->normalizeString($files['name']);
$mime_type = mime_content_type($feed_tmp_filename);
if ($mime_type == 'image/jpg' || $mime_type == 'image/jpeg' || $mime_type == 'image/png') {
$file_type = Feed::FILE_TYPE_IMAGE;
} else if ($mime_type == 'video/webm' || $mime_type == 'video/mpeg' || $mime_type == 'video/mpg' || $mime_type == 'video/mp4') {
$file_type = Feed::FILE_TYPE_VIDEO;
} else if ($mime_type == 'application/pdf') {
$file_type = Feed::FILE_TYPE_DOCUMENT;
}
}
//preview
$fileImg = $this->params()->fromFiles('image');
if (isset($fileImg) && empty($fileImg['error'])) {
$img_tmp_filename = $fileImg['tmp_name'];
$img_filename = $this->normalizeString($fileImg['name']);
} else {
$img_tmp_filename = null;
$img_filename = null;
}
$feedMapper = FeedMapper::getInstance($this->adapter);
$feed = $feedMapper->fetchOne($feed->id);
$hydrator = new ObjectPropertyHydrator();
$hydrator->hydrate($dataPost, $feed);
$categoriesMapper = TopicMapper::getInstance($this->adapter);
$category = $categoriesMapper->fetchOneByUuidOrTitle($categoryUuid);
$feed->topic_id = $category->id;
$feed->status = Feed::STATUS_SAVED;
if ($feedMapper->update($feed)) {
if ($file_type == Feed::FILE_TYPE_DOCUMENT) {
$target_path = $this->config['leaderslinked.fullpath.feed'] . $feed->uuid;
if (!file_exists($target_path)) {
mkdir($target_path, 0755);
}
Functions::deleteFilename($target_path, $feed->file_name);
$full_filename = $target_path . DIRECTORY_SEPARATOR . $feed_filename;
$result = move_uploaded_file($feed_tmp_filename, $full_filename);
if ($result) {
$feed->file_type = $file_type;
$feed->file_name = basename($feed_filename);
$feedMapper->update($feed);
} else {
error_log('no se pudo mover o renombrar el documento : ' . $feed_tmp_filename . ' al directorio : ' . $full_filename);
}
}
if ($file_type == Feed::FILE_TYPE_IMAGE) {
$target_path = $this->config['leaderslinked.fullpath.feed'] . $feed->uuid;
if (!file_exists($target_path)) {
mkdir($target_path, 0755);
}
Functions::deleteFilename($target_path, $feed->file_name);
list($target_width, $target_height) = explode('x', $this->config['leaderslinked.image_sizes.feed_image_size']);
$feed_filename = substr($feed_filename, 0, strrpos($feed_filename, '.')) . '.png';
$crop_to_dimensions = false;
if (Image::uploadImage($feed_tmp_filename, $target_path, $feed_filename, $target_width, $target_height, $crop_to_dimensions)) {
$feed->file_type = $file_type;
$feed->file_name = basename($feed_filename);
$feedMapper->update($feed);
}
}
if ($file_type == Feed::FILE_TYPE_VIDEO) {
$target_path = $this->config['leaderslinked.fullpath.feed'] . $feed->uuid;
if (!file_exists($target_path)) {
mkdir($target_path, 0755);
}
Functions::deleteFilename($target_path, $feed->file_name);
Functions::deleteFilename($target_path, $feed->file_image_preview);
$full_filename = $target_path . DIRECTORY_SEPARATOR . $feed_filename;
$result = move_uploaded_file($feed_tmp_filename, $full_filename);
if ($result) {
$size = $this->config['leaderslinked.image_sizes.feed_image_size'];
$getFromSecound = 2;
//extracción del cover
$generateFileName = substr($feed_filename, 0, strrpos($feed_filename, '.'));
$generateFile = $target_path . DIRECTORY_SEPARATOR . $generateFileName . '.png';
$cmd = "/usr/bin/ffmpeg -i $full_filename -an -ss $getFromSecound -s $size $generateFile";
exec($cmd);
$feed->file_type = $file_type;
$feed->file_name = basename($feed_filename);
$feed->file_image_preview = basename($generateFile);
$feedMapper->update($feed);
$videoConvert = new VideoConvert();
$videoConvert->filename = $full_filename;
$videoConvert->type = VideoConvert::TYPE_FEED;
$videoConvertMapper = VideoConvertMapper::getInstance($this->adapter);
$videoConvertMapper->insert($videoConvert);}
}
if ($file_type != Feed::FILE_TYPE_VIDEO && !empty($img_tmp_filename) && !empty($img_filename)) {
$target_path = $this->config['leaderslinked.fullpath.feed'] . $feed->uuid;
if (!file_exists($target_path)) {
mkdir($target_path, 0755);
}
Functions::deleteFilename($target_path, $feed->file_image_preview);
list($target_width, $target_height) = explode('x', $this->config['leaderslinked.image_sizes.feed_image_size']);
$img_filename = substr($img_filename, 0, strrpos($img_filename, '.')) . '.png';
if (Functions::uploadImage($img_tmp_filename, $target_path, $img_filename, $target_width, $target_height)) {
$feed->file_image_preview = basename($img_filename);
$feedMapper->update($feed);
}
}
$response = [
'success' => true,
'data' => 'success'
];
} else {
$messages = [];
$form_messages = (array) $form->getMessages();
foreach ($form_messages as $fieldname => $field_messages) {
$messages[$fieldname] = array_values($field_messages);
}
$response = [
'success' => false,
'data' => $messages
];
}
} else {
$response = [
'success' => false,
'data' => 'ERROR_METHOD_NOT_ALLOWED'
];
}
return new JsonModel($response);
}
}
}