/** * @param $transaction_number * @param null $terminal_id * @return string */ public function getCallnumber($transaction_number, $terminal_id) { try { if (is_null(TerminalTransaction::find($transaction_number))) { return json_encode(['error' => 'You have called an invalid input.']); } $terminal_transaction = TerminalTransaction::find($transaction_number); $priority_queue = PriorityQueue::find($transaction_number); if ($terminal_transaction->time_called != 0) { return json_encode(['error' => 'Number ' . $priority_queue->priority_number . ' has already been called. Please call another number.']); } else { return ProcessQueue::callTransactionNumber($transaction_number, Helper::userId(), $terminal_id); } } catch (Exception $e) { return json_encode(['error' => $e->getMessage()]); } }