You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.2 KiB

<?php
namespace app\Actions;
use Throwable;
use app\Repositories\QueueRepository;
class ListAllQueueWhatsAppAction
{
protected QueueRepository $queueRepository;
public function __construct()
{
$this->queueRepository = new QueueRepository;
}
function __invoke($option = null, string $id_empresa)
{
try {
$response = ['QUEUE' => '', 'LIST' => ''];
$search = $this->queueRepository->list(['id_empresa' => $id_empresa]);
$strmsg = "Informe o numero do setor para o atendimento: \n";
$count = 1;
if (count($search) == 1) {
$response['QUEUE'] = $search[0]->nome;
return $response;
}
foreach ($search as $q) {
if ($option == $count || $option == $q->nome) {
$response['QUEUE'] = $q->nome;
return $response;
}
$strmsg .= "{$count}. *{$q->nome}* \n";
$count++;
}
$response['LIST'] = $strmsg;
return $response;
}
catch (Throwable $ex) {
logger()->error($ex->getMessage());
}
return false;
}
}