119 lines
3.7 KiB
PHP
119 lines
3.7 KiB
PHP
<?php
|
|
|
|
namespace App\Controllers;
|
|
|
|
use App\Helpers\MailHelper;
|
|
use App\Helpers\sendMailNotification;
|
|
|
|
use App\Models\EmployeeModel;
|
|
use App\Models\EmployeePolicyModel;
|
|
use App\Models\ClientModel;
|
|
use App\Models\ClientRMModel;
|
|
use App\Models\PolicesModel;
|
|
use App\Models\RelationshipModel;
|
|
use App\Models\FileModel;
|
|
use App\Models\ClientPolicyModel;
|
|
use App\Models\PolicyPremium1Model;
|
|
use App\Models\PolicyPremium2Model;
|
|
use App\Models\PolicyTypeModel;
|
|
use App\Models\NotificationModel;
|
|
use App\Models\UserModel;
|
|
use App\Models\FEContentModel;
|
|
use App\Models\AddImgModel;
|
|
use App\Models\ChatBotModel;
|
|
|
|
use CodeIgniter\API\ResponseTrait;
|
|
|
|
class ChatBotController extends AdminController
|
|
{
|
|
|
|
use ResponseTrait;
|
|
|
|
protected $myLogger;
|
|
protected $employeeModel;
|
|
protected $employeePolicyModel;
|
|
protected $clientModel;
|
|
protected $clientRMModel;
|
|
protected $fileModel;
|
|
protected $policesModel;
|
|
protected $relationshipModel;
|
|
protected $clientPolicyModel;
|
|
protected $policyPremium1Model;
|
|
protected $policyPremium2Model;
|
|
protected $policyTypeModel;
|
|
protected $notificationModel;
|
|
protected $userModel;
|
|
protected $feContentModel;
|
|
protected $addImgModel;
|
|
protected $ChatBotModel;
|
|
|
|
public function __construct()
|
|
{
|
|
|
|
set_session_context('Employee');
|
|
$this->myLogger = \Config\Services::mylogger();
|
|
$this->employeeModel = new EmployeeModel();
|
|
$this->employeePolicyModel = new EmployeePolicyModel();
|
|
$this->clientModel = new ClientModel();
|
|
$this->clientRMModel = new ClientRMModel();
|
|
$this->policesModel = new PolicesModel();
|
|
$this->relationshipModel = new RelationshipModel();
|
|
$this->fileModel= new FileModel();
|
|
$this->clientPolicyModel = new ClientPolicyModel();
|
|
$this->policyPremium1Model = new PolicyPremium1Model();
|
|
$this->policyPremium2Model = new PolicyPremium2Model();
|
|
$this->policyTypeModel = new PolicyTypeModel();
|
|
$this->notificationModel = new NotificationModel();
|
|
$this->userModel = new UserModel();
|
|
$this->feContentModel = new FEContentModel();
|
|
$this->addImgModel = new AddImgModel();
|
|
$this->ChatBotModel = new ChatBotModel();
|
|
}
|
|
|
|
|
|
public function getChatResponse()
|
|
{
|
|
// try {
|
|
$request_for = $this->request->getGet('request_for');
|
|
$option = $this->request->getGet('option');
|
|
|
|
$requestData = $this->ChatBotModel->where('request', $request_for)
|
|
->where('is_active', 1 )
|
|
->first();
|
|
|
|
if ($requestData) {
|
|
|
|
|
|
|
|
if($option != 0){
|
|
|
|
$decodedData = json_decode($requestData['options'],true);
|
|
|
|
$requestFor = $decodedData[$request_for][$option];
|
|
|
|
$requestData = $this->ChatBotModel->where('request', $requestFor)
|
|
->where('is_active', 1 )
|
|
->first();
|
|
}
|
|
|
|
|
|
$result = ['request_for'=>$requestData['request'],'options'=>json_decode($requestData['options'],true)];
|
|
return $this->respond(['status' => 'success','code' => 200,'data' => $result ],200);
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
return $this->respond(['status' => 'failed','code' => 404,'data' => 'No Data'],404);
|
|
}
|
|
// } catch (\Throwable $th) {
|
|
// return $this->respond(['status' => 'failed','code' => 500,'data' => $th],500);
|
|
// }
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|