nhance/app/Helpers/ChatbotHelper.php
2025-02-03 10:26:49 +05:30

66 lines
2.0 KiB
PHP

<?php
// File: App\Helpers\DepositHelper.php
namespace App\Helpers;
use App\Models\EmployeeModel;
use App\Models\CDMasterModel;
use App\Models\EmployeePolicyModel;
use App\Models\TPAModel;
class ChatbotHelper
{
//get list of policies againest an employee_id
public static function getListOfPolicies()
{
$emp_id = 12288;
$emp_code = 'HTL-007';
$client_id = 159;
$policy_id = 0;
$client_branch_id = 126;
$relationship ='Father';
$EmployeeModel = new EmployeeModel();
return $EmployeeModel->getEmpFamilybyEmpCode(emp_code: $emp_code,client_id: $client_id,emp_status: ['draft'],policy_status:['draft'],client_branch_id:[ $client_branch_id ],relationship:[$relationship]);
}
public static function getHospitalLink(){
$client_policy_id = 336;
$emp_id = 12288;
$EmployeePolicyModel = new EmployeePolicyModel();
return $EmployeePolicyModel->getHospitalLinkByPolicyandEmp(336,12288);
}
public static function getPhoneNumber(){
$emp_id = 12288;
$EmployeeModel = new EmployeeModel();
return $EmployeeModel->select('mobile')->where('id',$emp_id)->first()['mobile'];
}
public static function get_payload_data(string $key = null)
{
// Get the request object using the service helper
$request = service('request');
// Get the raw input (JSON or other data)
$rawInput = $request->getBody();
// Check if the raw input is valid JSON
$payload = json_decode($rawInput, true);
if (json_last_error() === JSON_ERROR_NONE) {
// JSON is valid, return the requested key or the entire payload
return $key ? ($payload[$key] ?? null) : $payload;
} else {
// JSON is invalid, fallback to raw input or POST data
$payload = $request->getRawInput() ?: $request->getPost();
return $key ? ($payload[$key] ?? null) : $payload;
}
}
}
?>