initial commit

This commit is contained in:
2026-06-29 13:00:18 +06:00
commit f2aea74471
3931 changed files with 562423 additions and 0 deletions

15
.editorconfig Normal file
View File

@@ -0,0 +1,15 @@
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false
[*.{yml,yaml}]
indent_size = 2

70
.env.example Normal file
View File

@@ -0,0 +1,70 @@
APP_NAME=CCE
APP_ENV=local
APP_KEY=base64:a6HfIsB2Qq/H6/0oWTJpdHr2jsb9F7/JGpmWWXHwgZA=
APP_DEBUG=true
APP_URL=http://localhost/cce/public
API_BASE_URL=${APP_URL}/api
APP_BASE_ROUTE="/user"
LOG_CHANNEL=daily
COMPANY_NAME = 'Credit Counsel Elite'
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=credit_assistance
DB_USERNAME=root
DB_PASSWORD=
BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
SESSION_LIFETIME=120
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_MAILER=smtp
MAIL_HOST=sandbox.smtp.mailtrap.io
MAIL_PORT=587
mail_username=7436b107cde5b1
MAIL_PASSWORD=18de24b3571fd7
MAIL_ENCRYPTION=tls
mail_from_address=test.velocity@gmail.com
MAIL_FROM_NAME="${APP_NAME}"
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
WKHTML_PDF_BINARY = '"C:\wkhtmltopdf\bin\wkhtmltopdf.exe --enable-local-file-access"'
CLIENT_KEY="ddeada92-6310-4850-82c4-0b99159b9339"
SMART_CREDIT_BASE_URL = "https://stage-sc.consumerdirect.app"
PWS_SMART_CREDIT_BASE_URL = "https://stage-pws.consumerdirect.com"
SYSTEM_PASSWORD="cz@2030!"
LOGIN_TYPE='PARTNER_API'
REPORT_PROVIDER = "1"
# REPORT_PROVIDER_NAME = "3- SMART_CREDIT , 1-IDENTITY_IQ"
IS_QUEUE_ENABLE = "0"
#SMART_CREDIT_REPORT_BY_JSON = "1"
DEFAULT_ADMIN = 'jesse@clickletters.com'
DEFAULT_EMPLOYEE = 'lila@m2cacademy.com'
VIDEO_URL = 'https://player.vimeo.com/video/648879906?h=c6b29e5148&title=0&byline=0&portrait=0'
TECHNICAL_SUPPORT = 'https://www.clickmailedit.com/optin1615051099402'

5
.gitattributes vendored Normal file
View File

@@ -0,0 +1,5 @@
* text=auto
*.css linguist-vendored
*.scss linguist-vendored
*.js linguist-vendored
CHANGELOG.md export-ignore

32
.gitignore vendored Normal file
View File

@@ -0,0 +1,32 @@
# These are some examples of commonly ignored file patterns.
# You should customize this list as applicable to your project.
# Learn more about .gitignore:
# https://www.atlassian.com/git/tutorials/saving-changes/gitignore
# Node artifact files
node_modules/
/node_modules
/public/hot
/public/storage
/storage/*.key
/vendor
# JetBrains IDE
.idea/
.env
.env.backup
.phpunit.result.cache
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log
package-lock.json
.idea/*
storage/BAK/
storage/epicvelocity/letters/account/38/1.html
.idea/workspace.xml
app/Http/Controllers/TestController.php
public/report/
scrapper/

13
.styleci.yml Normal file
View File

@@ -0,0 +1,13 @@
php:
preset: laravel
disabled:
- unused_use
finder:
not-name:
- index.php
- server.php
js:
finder:
not-name:
- webpack.mix.js
css: true

96
README.md Normal file
View File

@@ -0,0 +1,96 @@
## Businesscreditassistance
A web application to upload report from another application and generate report based on client information in the system.
------------------------------------------------------------------------
## 🏗 Project Architecture
app/
├── Http/
│ ├── Controllers/
│ └── Requests/
├── Models/
├── Providers/
├── Services/
routes/
├── web.php
------------------------------------------------------------------------
## ⚙️ Requirements
- PHP ≥ 8.1
- Composer
- MySQL
- Laravel 8
- wkhtmltopdf
------------------------------------------------------------------------
## 🛠 Installation
``` bash
git clone <repository-url>
cd <project-name>
composer install
cp .env.example .env
php artisan key:generate
```
## Snappy pdf binary file
``` bash
Add snappy pdf binary file inside C:\wkhtmltopdf which added in onedrive
```
### Database
Import database script inside file location database>>ceditzombiesdb.sql
------------------------------------------------------------------------
## ▶️ Running the Project
``` bash
php artisan serve
```
Base API URL:
http://127.0.0.1:8000
------------------------------------------------------------------------
## 📄 Key Features
``` bash
1. Users Role : Admin, Employee, Client
```
``` bash
Admin or Employee Panel
1. Client Management
Admin or Employee Can Add, Edit, View and Delete client.
2. Employee Management
Admin or Permitted Employee Can Add, Edit, View and Delete employee.
3. Client Support
Admin or Permitted Employee Can reply the client support.
```
``` bash
Client Panel
1. Account Information
Client Can Add, Update his/her information.
2. Work Area
Client can upload their credit report and generate report in this section.
4. Support
Client Can create the support ticket.
```
``` bash
1. Client can apply using registration form
```

View File

@@ -0,0 +1,114 @@
<?php
namespace App\Console\Commands;
use App\Models\Recurring;
use App\Models\Sale;
use App\Models\User;
use Illuminate\Console\Command;
class DataMigration extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'data:migration';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Command is created for only system data migration';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
// $this->info('Start updateLastProcessDate');
// $this->updateLastProcessDate();
// $this->info('End updateLastProcessDate');
//
//
// $this->info('Start updateUserAccessEndDateDate');
// $this->updateUserAccessEndDateDate();
// $this->info('End updateUserAccessEndDateDate');
}
// the function is for updating recurrings table last_process_date by sale created_at date
private function updateLastProcessDate()
{
$recurring_users = (new Recurring())->getRecurrings();
$logData['action'] = 'UPDATE_LAST_PROCESS_DATE';
if (!empty($recurring_users)) {
foreach ($recurring_users as $recurring_user) {
$sale_data = (new Sale())->getLatestSalesByUserId($recurring_user['user_id']);
if (!empty($sale_data)) {
$inputData['last_process_date'] = $sale_data['created_at'];
$result = $recurring_user->update($inputData);
// log data prepared
$logData['result'][] = [
'sale_data' => $sale_data,
'updated' => $result,
'user_id' => $recurring_user['user_id'],
'data' => $inputData
];
}
}
appLog($logData);
}
}
// the function is for updating users table user_access_end_date by sale created_at date
private function updateUserAccessEndDateDate()
{
$users = (new User())->getAllClients();
$logData['action'] = 'UPDATE_USER_ACCESS_END_DATE';
if (!empty($users)) {
foreach ($users as $user) {
if (!empty($user->last_payment_date)) {
$inputData['user_access_end_date'] = getDateAfterSpicificDay($user->last_payment_date, config('constant.PAYMENT_INTERVAL_DAY'));
$result = $user->update($inputData);
// log data prepared
$logData['result'][] = [
'updated' => $result,
'user_id' => $user->id,
'added_date' => config('constant.PAYMENT_INTERVAL_DAY'),
'data' => $inputData
];
}
}
appLog($logData);
}
}
}

View File

@@ -0,0 +1,217 @@
<?php
namespace App\Console\Commands;
use App\Models\Recurring;
use App\Models\Sale;
use App\Models\User;
use App\Services\Payment\GateWay;
use App\Services\Payment\Payment;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
class SubscriptionUpdateByCronJob extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'subscription:update';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Update subscription and payment date by payment api';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
$this->info('Start subscription:update');
$this->updateSubscription();
$this->info('End subscription:update');
}
private function updateSubscription()
{
$recurringData = (new Recurring())->getRecurringDataForScheduler();
$log_id = time() . rand();
$logData['log_id'] = $log_id;
$logData['action'] = "CLIENT_SUBSCRIPTION_UPDATE_START";
appLog($logData);
if (!empty($recurringData)) {
foreach ($recurringData as $recurring) {
$logData = [];
$logData['log_id'] = $log_id;
$logData['action'] = "CLIENT_SUBSCRIPTION_UPDATE_START_IN_LOOP";
appLog($logData);
$paymentData = [];
// dd(getStringToDateTime('20230130082542'));
$paymentData['start_date'] = getDateAfterSpicificDay($recurring['last_process_date'], 1, 'YmdHis');
$paymentData['end_date'] = getCurrentDateTime('YmdHis');
$paymentData['subscription_id'] = $recurring['subscription_id'];
$response = (new Payment(GateWay::getGateWayInstance(config('constant.PAYMENT_GATEWAY.NMI')), $paymentData))->getSubscriptionInfoBySubscriptionId();
// log api response
$logData = [];
$logData['log_id'] = $log_id;
$logData['action'] = "SUBSCRIPTION_FROM_API_LOG";
$logData['response'] = $response;
$logData['inputData'] = $recurring;
appLog($logData);
if (!empty($response['data'])) {
$search_data_by_date = $response['data'];
if (!array_key_exists(0, $search_data_by_date)) {
$search_data_by_date = [];
$search_data_by_date[] = $response['data'];
}
$logData = [];
$logData['log_id'] = $log_id;
$logData['action'] = "PER_RESPONSE_DATA";
$logData['data'] = $search_data_by_date;
appLog($logData);
foreach ($search_data_by_date as $item) {
if (!empty($item)) {
$logData_subscription['log_id'] = $log_id;
$logData_subscription['action_by_subscription_start'] = "CLIENT_SUBSCRIPTION_START";
$logData = [];
$logData['log_id'] = $log_id;
$logData['action'] = "PER_ITEM_DATA";
$logData['item'] = $item;
appLog($logData);
$date = isset($item['action']['date']) ? $item['action']['date'] : $item['action'][0]['date'];
// $last_payment_date = getStringToDateTime($item['action'][0]['date']);
$last_payment_date = getStringToDateTime($date);
try {
DB::beginTransaction();
// user update
/*
$user_input['last_payment_date'] = $last_payment_date;
$user_input['user_access_end_date'] = getDateAfterSpicificDay($last_payment_date, config('constant.PAYMENT_INTERVAL_DAY'));
$user_input['subscription_status'] = config('constant.SUBSCRIPTION_STATUS.SUBSCRIBED');
$user_input['status'] = config('constant.SUBSCRIPTION_STATUS.SUBSCRIBED');
(new User())->userupdate($user_input, $recurring['user_id']);
*/
$this->updateUserData($last_payment_date,$recurring['user_id']);
// recurring update
$recurring_input['last_process_date'] = $last_payment_date;
$recurring->update($recurring_input);
// sales insert
$this->insertSalesData($recurring,$last_payment_date,$item);
/*
$order_id = !empty($item['order_id']) ? $item['order_id'] : generateUniqueId();
$salesData['order_id'] = $order_id;
$salesData['cc_number'] = $item['cc_number'];
$salesData['status'] = "1";
$salesData['auth_code'] = '';
$salesData['transaction_id'] = $item['transaction_id'];
$salesData['ip'] = getClientIpAddress();
$salesData['user_id'] = $recurring['user_id'];
$salesData['recurring_id'] = $recurring['id'];
$salesData['created_at'] = $last_payment_date;
$saleData = (new Sale())->getDataByTransactionId($item['transaction_id']);
if (empty($saleData)) {
(new Sale())->createSale($salesData);
}
*/
$logData_subscription['message'] = 'Update and insert data successfully';
DB::commit();
} catch (\Exception $ex) {
DB::rollback();
$logData_subscription['message'] = $ex->getMessage();
}
$logData_subscription['transaction'] = $item;
$logData_subscription['action_by_subscription_end'] = "CLIENT_SUBSCRIPTION_END";
appLog($logData_subscription);
}
}
}
$logData = [];
$logData['log_id'] = $log_id;
$logData['action'] = "CLIENT_SUBSCRIPTION_UPDATE_END_IN_LOOP";
appLog($logData);
}
}
$logData = [];
$logData['log_id'] = $log_id;
$logData['action'] = "CLIENT_SUBSCRIPTION_UPDATE_END";
appLog($logData);
}
private function updateUserData($last_payment_date,$user_id)
{
$user_input['last_payment_date'] = $last_payment_date;
$user_input['user_access_end_date'] = getDateAfterSpicificDay($last_payment_date, config('constant.PAYMENT_INTERVAL_DAY'));
$user_input['subscription_status'] = config('constant.SUBSCRIPTION_STATUS.SUBSCRIBED');
$user_input['status'] = config('constant.SUBSCRIPTION_STATUS.SUBSCRIBED');
(new User())->userupdate($user_input, $user_id);
}
private function insertSalesData($recurring,$last_payment_date,$item)
{
$order_id = !empty($item['order_id']) ? $item['order_id'] : generateUniqueId();
$salesData['order_id'] = $order_id;
$salesData['cc_number'] = $item['cc_number'];
$salesData['status'] = "1";
$salesData['auth_code'] = '';
$salesData['transaction_id'] = $item['transaction_id'];
$salesData['ip'] = getClientIpAddress();
$salesData['user_id'] = $recurring['user_id'];
$salesData['recurring_id'] = $recurring['id'];
$salesData['created_at'] = $last_payment_date;
$saleData = (new Sale())->getDataByTransactionId($item['transaction_id']);
if (empty($saleData)) {
(new Sale())->createSale($salesData);
}
}
}

47
app/Console/Kernel.php Normal file
View File

@@ -0,0 +1,47 @@
<?php
namespace App\Console;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
//
];
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
// $schedule->command('inspire')->hourly();
$schedule->command('subscription:update')->twiceDaily(1, 13); // Run the task daily at 1:00 & 13:00
// $schedule->call(function (){
// dd('ok');
// info('run cronjob');
// })->everyMinute();
}
/**
* Register the commands for the application.
*
* @return void
*/
protected function commands()
{
$this->load(__DIR__.'/Commands');
require base_path('routes/console.php');
}
}

View File

@@ -0,0 +1,46 @@
<?php
namespace App\Exceptions;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Throwable;
class Handler extends ExceptionHandler
{
/**
* A list of the exception types that are not reported.
*
* @var array
*/
protected $dontReport = [
//
];
/**
* A list of the inputs that are never flashed for validation exceptions.
*
* @var array
*/
protected $dontFlash = [
'password',
'password_confirmation',
];
/**
* Register the exception handling callbacks for the application.
*
* @return void
*/
public function register()
{
//
}
public function render($request, Throwable $exception)
{
// appLog(["message"=>$exception->getMessage(),"line"=>$exception->getLine()]);
// return response()->view('errors.404', ['exception'=> $exception], 404);
return parent::render($request, $exception); // TODO: Change the autogenerated stub
}
}

918
app/Helper/helper.php Normal file
View File

@@ -0,0 +1,918 @@
<?php
if(!function_exists('cleanDirectory')) {
function cleanDirectory($folder_path, $recursive = false)
{
if(!is_dir($folder_path)){
return false;
}
$files = glob($folder_path.'/*');
foreach ($files as $file){
@unlink($file);
}
}
}
if(!function_exists('uploadFile')){
function uploadFile($file_path,$file_name,$content){
app('ManageFile')->uploadFile($file_path,$file_name,$content);
}
}
if(!function_exists('getFile')){
function getFile($file_path){
return app('ManageFile')->getFile($file_path);
}
}
if(!function_exists('uploadHTML')){
function uploadHTML($file_path,$file_name,$content){
return app('ManageFile')->uploadHTML($file_path,$file_name,$content);
}
}
if(!function_exists('deleteFile')){
function deleteFile($file_path){
return app('ManageFile')->deleteFile($file_path);
}
}
if(!function_exists('getPublicFile')){
function getPublicFile($file_path){
$file_path = config('constant.MAIN_DIR').DIRECTORY_SEPARATOR.$file_path;
return \Illuminate\Support\Facades\Storage::disk('public')->exists($file_path) ? asset(Illuminate\Support\Facades\Storage::url($file_path)):"";
}
}
if(!function_exists('getSupportFile')){
function getSupportFile($file_path){
return asset('storage/resources/support_ticket/'.$file_path);
}
}
if(!function_exists('getPublicImageFile')){
function getPublicImageFile($file_path){
$file_path = config('constant.MAIN_DIR').DIRECTORY_SEPARATOR.$file_path;
$dir_path = 'storage/';
return \Illuminate\Support\Facades\Storage::disk('public')->exists($file_path) ? $dir_path.$file_path :"";
}
}
if(!function_exists('appLog')){
function appLog($data){
app('ManageLogging')->createLog($data);
}
}
if(!function_exists('generateOrderId')) {
function generateOrderId(): string
{
return time() . rand(10000, 99999);
}
}
if(!function_exists('generateUniqueId')) {
function generateUniqueId(): string
{
return time() . rand(10000, 99999);
}
}
if(!function_exists('getClientIpAddress')) {
function getClientIpAddress(): string
{
$ipaddress = '';
if (isset($_SERVER['HTTP_CLIENT_IP']))
$ipaddress = $_SERVER['HTTP_CLIENT_IP'];
else if (isset($_SERVER['HTTP_X_FORWARDED_FOR']))
$ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
else if (isset($_SERVER['HTTP_X_FORWARDED']))
$ipaddress = $_SERVER['HTTP_X_FORWARDED'];
else if (isset($_SERVER['HTTP_FORWARDED_FOR']))
$ipaddress = $_SERVER['HTTP_FORWARDED_FOR'];
else if (isset($_SERVER['HTTP_FORWARDED']))
$ipaddress = $_SERVER['HTTP_FORWARDED'];
else if (isset($_SERVER['REMOTE_ADDR']))
$ipaddress = $_SERVER['REMOTE_ADDR'];
else
$ipaddress = 'UNKNOWN';
if (strlen($ipaddress) > 45) {
$ipaddress = substr($ipaddress, 0, 45);
}
return $ipaddress;
}
}
if(!function_exists('setUserId')) {
function setUserId($id){
setContainerValue('user_id',$id);
}
}
if(!function_exists('setSecurityKey')) {
function setSecurityKey($value){
setContainerValue('security_key',$value);
}
}
if(!function_exists('getSecurityKey')) {
function getSecurityKey(){
if(auth()->check()){
return customEncrypt(auth()->id());
}
return getContainerValue('security_key');
}
}
if(!function_exists('setContainerValue')) {
function setContainerValue($key,$value){
\App\Services\CustomContainer::setContainer($key, $value);
}
}
if(!function_exists('getContainerValue')) {
function getContainerValue($key){
return \App\Services\CustomContainer::getContainer($key);
}
}
if(!function_exists('getUserId')) {
function getUserId(){
return \App\Services\CustomContainer::getContainer('user_id');
}
}
if(!function_exists('getAvailableWave')) {
function getAvailableWave(){
return session('available_wave');
}
}
if(!function_exists('setAvailableWave')) {
function setAvailableWave($wave){
return session('available_wave',$wave);
}
}
if(!function_exists('customEncrypt')) {
function customEncrypt($string){
return (new \App\Services\OpenSSLCryptoClass())->encrypt_decrypt('encrypt',$string);
}
}
if(!function_exists('customDecrypt')) {
function customDecrypt($string){
return (new \App\Services\OpenSSLCryptoClass())->encrypt_decrypt('decrypt',$string);
}
}
if(!function_exists('getCurrentDate')) {
function getCurrentDate($format = 'Y-m-d')
{
$dt = \Carbon\Carbon::now();
return $dt->format($format);
}
}
if(!function_exists('getCurrentDateTime')) {
function getCurrentDateTime($format = 'Y-m-d H:i:s')
{
$dt = \Carbon\Carbon::now();
return $dt->format($format);
}
}
if(!function_exists('getStringToDate')) {
function getStringToDate($stringDate,$format = 'Y-m-d')
{
$date=strtotime($stringDate);
return date($format, $date);
}
}
if(!function_exists('getStringToDateTime')) {
function getStringToDateTime($stringDate,$format = 'Y-m-d H:i:s')
{
$date=strtotime($stringDate);
return date($format, $date);
}
}
if(!function_exists('setSession')) {
function setSession($key,$value)
{
return session()->put($key,$value);
}
}
if(!function_exists('getSession')) {
function getSession($key)
{
return session()->get($key);
}
}
if(!function_exists('getDateDifference')) {
// compare with current date time
function getDateDifference($date,$type = 'day')
{
if($type == 'day'){
return \Carbon\Carbon::now()->diffInDays($date);
}else if($type == 'min'){
return \Carbon\Carbon::now()->diffInMinutes($date);
}else if($type == 'year'){
return \Carbon\Carbon::now()->diffInYears($date);
}
}
}
if(!function_exists('getDateAfterSpicificDay')) {
// compare with current date time
function getDateAfterSpicificDay($date,$interval,$format = 'Y-m-d H:i:s')
{
$interval_data = $interval.' days';
return date($format,strtotime($interval_data, strtotime($date)));
}
}
if(!function_exists('unSetSession')) {
function unSetSession($key)
{
return session()->forget($key);
}
}
if(!function_exists('getWaveList')) {
function getWaveList($key)
{
return session()->forget($key);
}
}
if(!function_exists('isEmployee')) {
function isEmployee()
{
return auth()->user()->user_type == 2;
}
}
if(!function_exists('isAdmin')) {
function isAdmin()
{
return auth()->user()->user_type == 1;
}
}
if(!function_exists('isSupport')) {
function isSupport()
{
return auth()->user()->email == "cce_support@gmail.com";
}
}
if(!function_exists('isClient')) {
function isClient()
{
return (auth()->user()->user_type == 0 || auth()->user()->user_type == 3);
}
}
if(!function_exists('setCache')) {
function setCache($key,$value)
{
return cache()->put($key,$value);
}
}
if(!function_exists('getCache')) {
function getCache($key)
{
return cache()->get($key) ?? null;
}
}
if(!function_exists('unsetCache')) {
function unsetCache($key)
{
return cache()->forget($key);
}
}
if(!function_exists('getSection')) {
function getSection()
{
return config('constant.SECTION_NAME')??[];
}
}
if(!function_exists('getSectionById')) {
function getSectionById($id)
{
return config('constant.SECTION_NAME')[$id] ?? null;
}
}
if(!function_exists('getSectionIdByKey')) {
function getSectionIdByKey($key)
{
return config('constant.SECTION_IDS.'.$key) ?? null;
}
}
if(!function_exists('setCookies')) {
function setCookies($key,$value)
{
setcookie(
$key,
$value,
time() + (10 * 365 * 24 * 60 * 60)
);
return $value;
}
}
if(!function_exists('getCookie')) {
function getCookie($key)
{
$c_key = $key;
// return \Cookie::get($key);
// return request()->cookie($key);
return $_COOKIE[$c_key];
}
}
if(!function_exists('unsetCookie')) {
function unsetCookie($key)
{
return Cookie::forget($key);
}
}
if(!function_exists('cookieExitOrNot')) {
function cookieExitOrNot($key)
{
return Cookie::has($key);
}
}
if(!function_exists('isClientSubscription')) {
function isClientSubscription()
{
return auth()->user()->subscription_status == config('constant.SUBSCRIPTION_STATUS.SUBSCRIBED');
}
}
if(!function_exists('decisionFromClientWave')) {
function decisionFromClientWave()
{
$current_wave = auth()->user()->wave;
$day_interval = config('constant.PACKAGE_INTERVAL_DAY');
$decisionWaves = [];
for($i = 1 ; $i<= $current_wave; $i++) {
$day_start = ($day_interval * ($i - 1));
$start = 1;
$end = $day_interval;
if ($i > 1) {
$start = $day_start + ($i - 1);
$end = $start + $day_interval;
}
$wave_text = "I want to use a Wave $i attack for this content box's items ( Day $start - $end )";
$wave_value = "w$i";
$decisionWaves[$i]['key'] = $wave_value;
$decisionWaves[$i]['text'] = $wave_text;
}
return $decisionWaves;
// return ['wave_text'=>$wave_text,'wave_value'=>$wave_value];
}
}
if(!function_exists('creditCardNumberMasking')) {
function creditCardNumberMasking($number, $maskingCharacter = '*')
{
return str_repeat($maskingCharacter, strlen($number) - 4) . substr($number, -4);
}
}
if(!function_exists('sizeFilter')){
function sizeFilter( $size )
{
$sizes = ['KB', 'MB', 'GB'];
$count=0;
if ($size >= 1024) {
while ($size >= 1024) {
$size = round($size / 1024);
$count++;
}
}
return $size .$sizes[$count];
}
}
if(!function_exists('getPaymentStatus')){
function getPaymentStatus( $status)
{
$result = '<span class="text-danger"> failed </span>';
if (!empty($status)) {
$result = '<span class="text-success"> success </span>';
}
return $result;
}
}
if(!function_exists('getAccountStatus')){
function getAccountStatus($subscription_status, $status)
{
$result = '<span class="text-danger"> Inactive </span>';
if ($status == config('constant.ACCOUNT_STATUS.Active')) {
$result = '<span class="text-success"> Active </span>';
if($subscription_status == config('constant.SUBSCRIPTION_STATUS.CANCEL_ACCOUNT')){
$result = '<span class="text-danger"> Canceled </span>';
}
}
return $result;
}
}
if(!function_exists('getNextImportDate')) {
function getNextImportDate()
{
$date = getCurrentDate('m/d/Y');
if(Auth::user()->last_import_date!=null) {
$date = getDateAfterSpicificDay(Auth::user()->last_import_date, config('constant.PACKAGE_INTERVAL_DAY'), 'm/d/Y');
}
return $date;
}
}
if(!function_exists('isPermitted')) {
function isPermitted()
{
$result = false;
$current_route_name = request()->route()->getName();
$get_route_list = getSession('permissions_route_list');
if(in_array($current_route_name,$get_route_list)){
$result = true;
}
return $result;
}
}
if(!function_exists('isShowContent')) {
function isShowContent($route_name)
{
$result = false;
$get_route_list = getSession('permissions_route_list');
if(isEmployee()) {
if (in_array($route_name, $get_route_list)) {
$result = true;
}
}else{
$result = true;
}
return $result;
}
}
if(!function_exists('addDays')) {
function addDays($day,$date,$format = 'Y-m-d H:i:s'){
return \Carbon\Carbon::parse($date)->addDays($day)->format($format);
}
}
if(!function_exists('clientWaves')) {
function clientWaves($current_wave=null)
{
$waves = [];
if(empty($current_wave)) {
$current_wave = auth()->user()->wave;
}
for($i=1 ; $i<= $current_wave ; $i++)
{
$waves[$i]['key'] = $i;
$waves[$i]['text'] = 'Wave '. $i;
}
return $waves;
}
}
if(!function_exists('imageFileRotate')){
function imageFileRotate($imageFile){
$image = file_get_contents($imageFile);
$exif = [];
try {
$exif = exif_read_data($imageFile);
if(!empty($exif['Orientation']) && matchExifOrientation($exif['Orientation']) ) {
$format = $exif['MimeType'];
$rotated = '';
$temp = '';
$photo = $imageFile;
if( $format == 'image/jpeg' || $format == 'image/jpg') {
$temp = imagecreatefromjpeg($photo);
} elseif( $format == 'image/png' ) {
$temp = imagecreatefrompng($photo);
} elseif( $format == 'image/gif' ) {
$temp = imagecreatefromgif($photo);
}
switch($exif['Orientation']) {
case 8:
$rotated = imagerotate($temp,90,0);
break;
case 3:
$rotated = imagerotate($temp,180,0);
break;
case 6:
$rotated = imagerotate($temp,-90,0);
break;
}
$extension = $photo->getClientOriginalExtension();
$flieNametoStore = time() . "___" . explode('.', $photo->getClientOriginalName())[0] . '.' . $extension;
ob_start();
imagejpeg($rotated);
$image = ob_get_contents();
ob_clean();
}
}catch (Exception $ex){
}
return $image;
}
}
if(!function_exists('matchExifOrientation')) {
function matchExifOrientation($orientation)
{
return match ($orientation){
3,6,8 => true,
default => false
};
}
}
if(!function_exists('getCreditReportPersonalInfo')) {
function getCreditReportPersonalInfo($data,$key)
{
$result = '';
if($key == 'NAME') {
$result = $data['Name']['first'] . ' ' . $data['Name']['middle'] . ' ' . $data['Name']['last'] . ' ';
}
elseif($key == 'ALSO_KNOWN_AS') {
$result = $data['Name']['first'] . ' ' . $data['Name']['middle'] . ' ' . $data['Name']['last'] . ' ';
}
elseif($key == 'CREDIT_REPORT_DATE') {
$result = getStringToDateTime($data['Source']['InquiryDate'],'m/d/Y') ;
}
elseif($key == 'DATE_OF_BIRTH') {
$result = $data['BirthDate']['year'] . ' ';
}
elseif($key == 'CURRENT_ADDRESS' || $key == 'PREVIOUS_ADDRESS') {
if($data['Source']['Bureau']['symbol'] == 'TUC'){
$result = $data['CreditAddress']['houseNumber'].' '.$data['CreditAddress']['streetName'].' ';
}else{
$result = $data['CreditAddress']['unparsedStreet'].' ' ;
}
$result =$result.$data['CreditAddress']['city'] . ', ' . $data['CreditAddress']['stateCode'].' ' . $data['CreditAddress']['postalCode'] . ' ';
if (isset($data['dateUpdated'])) {
$result = $result. "Date Updated: " . getStringToDateTime($data['dateUpdated'],'m/Y') ;
}
} elseif($key == 'EMPLOYER') {
$result = $data['name'] . ' ';
if (isset($data['dateUpdated'])) {
$result .= "Date Updated: " . getStringToDateTime($data['dateUpdated'],'m/Y');
}
}
return $result;
}
}
if(!function_exists('getCreditReportValuesExistOrNot')) {
function getCreditReportValuesExistOrNot($data,$key)
{
return (empty($data['data']['TransUnion']) && empty($data['data']['Experian']) && empty($data['data']['Equifax']) && $key != 'ALSO_KNOWN_AS');
}
}
if(!function_exists('getCreditReportAccountHistoryInfo')) {
function getCreditReportAccountHistoryInfo($data,$key)
{
$result = '';
if($key == 'ACCOUNT') {
$result = isset($data['accountNumber'])? accountNumberMasking($data['accountNumber']):'--';
}
elseif($key == 'HIGH_BALANCE') {
$result = isset($data['highBalance'])? amountFormatter($data['highBalance']) : '--';
}
elseif($key == 'LAST_VERIFIED') {
$result = isset($data['dateVerified'])? getStringToDateTime($data['dateVerified'],'m/d/Y') :'--';
}
elseif($key == 'DATE_OF_LAST_ACTIVITY') {
$result = isset($data['dateAccountStatus'])? getStringToDateTime($data['dateAccountStatus'],'m/d/Y') :'--';
}
elseif($key == 'DATE_REPORTED') {
$result = isset($data['dateReported'])? getStringToDateTime($data['dateReported'],'m/d/Y') :'--';
}
elseif($key == 'DATE_OPENED') {
$result = isset($data['dateOpened'])? getStringToDateTime($data['dateOpened'],'m/d/Y') :'--';
}
elseif($key == 'BALANCE_OWED') {
$result = isset($data['currentBalance'])?amountFormatter($data['currentBalance']) : '--';
}
elseif($key == 'CLOSED_DATE') {
$result = isset($data['dateClosed'])? getStringToDateTime($data['dateClosed'],'m/d/Y') :'--';
}
elseif($key == 'ACCOUNT_RATING') {
$result = $data['AccountCondition']['description']??'--';
}
elseif($key == 'ACCOUNT_DESCRIPTION') {
$result = $data['AccountDesignator']['description']??'--';
}
elseif($key == 'DISPUTE_STATUS') {
$result = $data['DisputeFlag']['description']??'--';
}
elseif($key == 'CREDITOR_TYPE') {
$result = $data['IndustryCode']['description']??'--';
}
elseif($key == 'ACCOUNT_STATUS') {
$result = $data['OpenClosed']['description']??'--';
}
elseif($key == 'PAYMENT_STATUS') {
$result = $data['PayStatus']['description']??'--';
}
elseif($key == 'CREDITOR_REMARKS') {
$remark_data = '--';
if(!empty($data['Remark'])) {
$remark_data = '';
if(isset($data['Remark']['RemarkCode'])){
$data['Remark'] = [ $data['Remark'] ];
}
foreach ($data['Remark'] as $remark) {
$remark_data = $remark_data . $remark['RemarkCode']['description'] .'<br>';
}
}
echo $remark_data;
}elseif($key == 'ORIGINAL_CREDITOR') {
$result = $data['CollectionTrade']['originalCreditor']??'--';
}
elseif($key == 'PAYMENT_AMOUNT') {
$result = isset($data['GrantedTrade']['monthlyPayment'])?amountFormatter($data['GrantedTrade']['monthlyPayment']):'--';
}
elseif($key == 'LAST_PAYMENT') {
$result = isset($data['GrantedTrade']['dateLastPayment'])? getStringToDateTime($data['GrantedTrade']['dateLastPayment'],'m/d/Y') :'--';
}
elseif($key == 'TERM_LENGTH') {
$result = !empty($data['GrantedTrade']['termMonths'])? $data['GrantedTrade']['termMonths'].' Month(s)' :'--';
}
elseif($key == 'PAST_DUE_AMOUNT') {
$result = isset($data['GrantedTrade']['amountPastDue'])?amountFormatter($data['GrantedTrade']['amountPastDue']):'--';
}
elseif($key == 'ACCOUNT_TYPE') {
$result = !empty($data['GrantedTrade']['AccountType']['description'])? $data['GrantedTrade']['AccountType']['description'] :'--';
}
elseif($key == 'PAYMENT_FREQUENCY') {
$result = !empty($data['GrantedTrade']['PaymentFrequency']['description'])? $data['GrantedTrade']['PaymentFrequency']['description'] : '--';
}
elseif($key == 'CREDIT_LIMIT') {
$result = isset($data['GrantedTrade']['CreditLimit'])? amountFormatter($data['GrantedTrade']['CreditLimit']) :'--';
}
return $result;
}
}
if(!function_exists('accountNumberMasking')) {
function accountNumberMasking($number, $maskingCharacter = '*')
{
return substr($number, 0, -4).str_repeat($maskingCharacter,4) ;
}
}
if(!function_exists('amountFormatter')) {
function amountFormatter($number,$currency='$')
{
return $currency.rtrim(rtrim(number_format($number, 2, '.', ','),'0'),'.');
}
}
if(!function_exists('getMonthlyPayStatus')) {
function getMonthlyPayStatus($monthlyPayStatus)
{
$status = '';
$url_first = 'https://www.smartcredit.com/resources/images/shared/tui/creditreport/tradeline-';
$url_last = '.gif';
$url_middle = '';
$pay_status = $monthlyPayStatus['status'];
if($pay_status == 'C'){
$status = 'OK';
$url_middle = 'ok';
}elseif ($pay_status == 'U'){
$status = 'unknown';
$url_middle = 'unknown';
}elseif ($pay_status == '5' || $pay_status == '4' || $pay_status == '3' || $pay_status == '2' || $pay_status == '1'){
$month = 30;
$status = ($pay_status*$month) .' days late';
$url_middle = ($pay_status*$month);
}elseif ($pay_status == '9' ){
$status = 'Collection Chargeoff';
$url_middle = 'co';
}
return ['status'=>$status,'url'=>$url_first.$url_middle.$url_last];
}
}
if(!function_exists('getPayStatusHistory')) {
function getPayStatusHistory($monthlyPayStatus)
{
$month = '';
$month = getStringToDateTime($monthlyPayStatus['date'],'M');
$months = (getStringToDateTime($monthlyPayStatus['date'],'m') == '01');
$year = getStringToDateTime($monthlyPayStatus['date'],'y');
$year_split = str_split($year);
$url_first = 'https://www.smartcredit.com/resources/images/shared/tui/creditreport/monthsandyears/';
$url_last = '-gray.gif';
$url1 = $url_first.$year_split[0].$url_last;
$url2 = $url_first.$year_split[1].$url_last;
$url3 = $url_first.strtolower($month).$url_last;
return ['isViewed'=>$months,'month'=>$month,'year_split_0'=>$year_split[0],'year_split_1'=>$year_split[1],'url1'=>$url1,'url2'=>$url2,'url3'=>$url3];
}
}
if(!function_exists('isRowVisibleInCreditReportHtml')) {
function isRowVisibleInCreditReportHtml($keys,$sub_account_history_data)
{
return (($keys == 'ORIGINAL_CREDITOR' && $sub_account_history_data['accountTypeSymbol']!='Y')||(($keys == 'PAYMENT_AMOUNT' || $keys == 'TERM_LENGTH' || $keys == 'PAYMENT_FREQUENCY' || $keys == 'CREDIT_LIMIT') && $sub_account_history_data['accountTypeSymbol']=='Y'));
}
}
if(!function_exists('getConsumerStatement')) {
function getConsumerStatement($data)
{
$result = 'NONE REPORTED';
if(!empty($data)){
$result = '';
foreach($data as $equifax){
$result = $result.$equifax['statement'] ;
}
}
return $result;
}
}
if(!function_exists('getModelDataMasking')) {
function getModelDataMasking($inputData)
{
if (!empty($inputData['password'])) {
$inputData['password'] = "*********";
}
if (!empty($inputData['full_ssn'])) {
$inputData['full_ssn'] = "*********";
}
if (!empty($inputData['security_key'])) {
$inputData['security_key'] = "*********";
}
if (!empty($inputData['card_number'])) {
$inputData['card_number'] = creditCardNumberMasking($inputData['card_number']);
}
// if(!empty($inputData['ssn']))
// {
// $inputData['ssn']="****";
// }
if(!empty($inputData['html_content']))
{
$inputData['html_content']="*********************************";
}
return $inputData;
}
}
if(!function_exists('getClientStatus')) {
function getClientStatus($inputData)
{
return ($inputData['status'] == 2 && $inputData['subscription_status'] == 0);
}
}
if(!function_exists('getUserImagesAndDoc')) {
function getUserImagesAndDoc($id)
{
$uploadMediaObj = app(\App\Models\Uploadmedia::class);
$upload_medias = $uploadMediaObj->getProfilePicByUserId($id);
$user_image = '';
$profile_image = '';
if($upload_medias->isNotEmpty()) {
$profile_image = $upload_medias->where('image_type_id',9)->pluck('image_path')->first();
$user_image = config('constant.UPLOAD_MEDIA_PATH') . DIRECTORY_SEPARATOR . $id . DIRECTORY_SEPARATOR . $profile_image;
}
setSession('user_image',$user_image);
setSession('profile_image',$profile_image);
}
}
if(!function_exists('getEnableImportReset')) {
function getEnableImportReset($data)
{
$result = false;
if ($data['status'] == 1 && $data['subscription_status'] == 1 && $data['is_import'] == 0){
$result = true;
}
return $result;
}
}
if(!function_exists('getSupportIsAdmin')) {
function getSupportIsAdmin($obj)
{
return (($obj->user_type == config('constant.USER_TYPE.ADMIN') && auth()->user()->user_type == config('constant.USER_TYPE.EMPLOYEE'))||
(auth()->user()->user_type == config('constant.USER_TYPE.ADMIN') && $obj->user_type == config('constant.USER_TYPE.EMPLOYEE'))||
(auth()->user()->user_type == config('constant.USER_TYPE.ADMIN') && $obj->user_type == config('constant.USER_TYPE.ADMIN')));
}
}
if(!function_exists('removeAnySpaces')) {
function removeAnySpaces($data,$replaceBy)
{
return preg_replace('/\s+/', $replaceBy, trim($data));
}
}

View File

@@ -0,0 +1,420 @@
<?php
namespace App\Http\Controllers;
use App\Models\Permission;
use App\Models\Uploadmedia;
use App\Models\User;
use App\Services\CreditReportService;
use App\Models\VideoSetting;
use App\Models\Support;
use App\Services\Package;
use App\Services\SmartCreditJsonToHtml;
use App\Utility\Email;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use phpDocumentor\Reflection\DocBlock\Tags\Uses;
class AjaxController extends Controller
{
private array $response = [
'status'=>false,
'message'=>'fail',
'type'=>'error',
'data'=>[]
];
public function processAjaxRequest(Request $request)
{
$logData=[];
$inputData = $request->all();
$action = $inputData['action'];
if($inputData['action'] == "GET_CREDIT_REPORT"){
$this->getCreditReport();
}
if($inputData['action'] == "GET_CREDIT_REPORT_REFRESH_BUTTON_CONTENT"){
$this->getCreditReportRefreshButtonContent($inputData);
}
if($inputData['action'] == "GET_CREDIT_REPORT_REFRESH_DATE")
{
$inputData = auth()->user();
$inputData['password'] = customDecrypt($inputData['password']);
$this->getSmartCreditRefreshDate($inputData);
}
if($inputData['action'] == "DELETE_RECURRING")
{
$postData['user_id']=auth()->user()->id;
$returnData= (new Package())->deleteRecurring($postData);
if($returnData) {
$this->response['message'] = 'Recurring has deleted successfully';
$this->response['code'] = config('constant.API_SUCCESS_CODE');
$this->response['type'] = 'success';
$this->response['status'] = true;
$this->response['data']['html'] = $returnData;
}
}
if($inputData['action'] == "SUBSCRIPTION_SMART_CREDIT")
{
$auth_user = auth()->user();
$type = config('constant.SUBSCRIPTION_SMART_CREDIT.SUBSCRIBE');
$type_id = config('constant.SUBSCRIPTION_STATUS.SUBSCRIBED');
if($auth_user->subscription_status == config('constant.SUBSCRIPTION_STATUS.SUBSCRIBED')){
$type = config('constant.SUBSCRIPTION_SMART_CREDIT.UNSUBSCRIBE');
$type_id = config('constant.SUBSCRIPTION_STATUS.CANCEL_ACCOUNT');
}
$inputData['user_id'] = $auth_user->id;
$inputData['type'] = $type;
$inputData['report_type'] = $auth_user->credit_report_company_type;
$inputData['type_id'] = $type_id;
$inputData['email'] = $auth_user->email;
$inputData['name'] = $auth_user->first_name.' '.$auth_user->last_name;
$this->customer_subscription_status_submit($inputData);
}
if($inputData['action'] == "DELETE_CLIENT_DOC_FILE")
{
$this->deleteDocFile($inputData);
}
if($inputData['action'] == "CLOSE_SUPPORT_TICKET")
{
$this->closeSupportTicket($inputData);
$inputData['userData'] = array_slice($inputData['userData'],0,8,false);
}
if($inputData['action'] == "REMINDER_SUPPORT_TICKET")
{
$this->sendReminder($inputData);
}
appLog($this->logDataCreate($action,getModelDataMasking($inputData),$this->response['message'],$this->response['status'],$this->response['code'] ?? ""));
return response()->json($this->response,200);
}
public function processAdminAjaxRequest(Request $request)
{
$inputData = $request->all();
$clientId =[];
if($inputData['action'] == "DELETE_CLIENT" || $inputData['action'] == "DELETE_EMPLOYEE")
{
$clientId = $inputData['userData'][0];
}
if($inputData['action'] == 'DELETE_MULTIPLE_CLIENT' || $inputData['action'] == "DELETE_MULTIPLE_EMPLOYEE"){
foreach ($inputData['userData'] as $user) {
$data = json_decode($user);
$clientId[] = $data[0];
}
}
$this->deleteClient($clientId,$inputData['delete_type']??'');
appLog($this->logDataCreate($inputData['action'],getModelDataMasking($inputData),$this->response['message'], "",$this->response['code'] ?? ""));
return response()->json($this->response,200);
}
public function processAdminGetAjaxRequest(Request $request)
{
$inputData = $request->all();
if($inputData['action'] == "GET_USER_PERMISSION")
{
$this->getUserPermission($inputData['id']);
}
if($inputData['action'] == "GET_SUBSCRIPTION_STATUS_CREDIT_REPORT_PROVIDER"){
$this->getSubscriptionStatusCreditReportProvider($inputData);
}
appLog($this->logDataCreate($inputData['action'],getModelDataMasking($inputData),$this->response['message'], $this->response['status'],$this->response['code'] ?? ""));
return response()->json($this->response,200);
}
private function getCreditReport(){
$auth_user = auth()->user();
$user_id = $auth_user->id;
$credit_report_type = $auth_user->credit_report_company_type;
$creditReport = (new CreditReportService())->getUpdatedReport($user_id,$credit_report_type,$auth_user->ssn);
if(empty($creditReport['credit_report_file_name']) && empty($creditReport['html'])){
$logData = [];
$this->response['code'] = config('constant.OTP_SUCCESS_CODE');
$this->response['status'] = true;
$email = $creditReport['credit_report_user_obj']['email'];
$password = $creditReport['credit_report_user_obj']['password'];
$this->response['data']['html'] = view('epicvelocity.one_time_password', ['email'=>$email,'password'=>$password])->render();
$logData['action'] = "ONE_TIME_PASSWORD_PAGE";
$logData['request'] = $email;
$logData['response'] = $this->response['code'];
appLog($logData);
return;
}
if($creditReport['status']){
if(config('app.SMART_CREDIT_REPORT_BY_JSON') == '1' && $credit_report_type == config('constant.reportType.SMART_CREDIT')) {
$creditReport['html'] = $this->generateHtml($creditReport['html']);
}
$this->response['status'] = true;
$this->response['message'] = "Credit Report info fetched successfully";
$this->response['code'] = config('constant.API_SUCCESS_CODE');
$this->response['data']['html'] = $creditReport['html'];
}else{
$this->response['status'] = false;
$this->response['message'] = "Can not fetched Data";
$this->response['code'] = config('constant.API_FAILED_CODE');
$this->response['data']['html'] = null;
}
}
private function getSmartCreditRefreshDate($inputData)
{
$this->response['status'] = false;
$response =[];
// $inputData['email'] = "stevetest@consumerdirect.com";
// $inputData['password'] ="12345678";
if($inputData->credit_report_company_type == config('constant.reportType.SMART_CREDIT')){
$response = (new CreditReportService())->getSmartCreditRefreshDate($inputData['email'], $inputData['password'], '');
}else if($inputData->credit_report_company_type == config('constant.reportType.IDENTITY_IQ')){
$response = (new CreditReportService())->getIdentityIQRefreshDate($inputData['email'], $inputData['password'], $inputData->ssn);
}
$this->response['message'] = "";
if(!empty($response)){
if ($response['refresh_date'] == "ERROR") {
$this->response['status'] = false;
$this->response['message'] = $response['message'];
}else{
$this->response['status'] = true;
$this->response['code'] = config('constant.API_SUCCESS_CODE');
$remove_view_text = "View Latest Report";
$remove_purchase_text = "Purchase Report";
$remove_refresh_text = "Refresh Report";
$remove_notfound_text = "Not Found";
$removetext = "Refresh Available";
$response['refresh_date'] = str_replace([$remove_view_text,$remove_purchase_text,$remove_refresh_text,$remove_notfound_text],"",$response['refresh_date']);
$response['refresh_date'] = str_replace("×\n","" , $response['refresh_date']);
$this->response['button_type'] = $response['button_type'];
$this->response['refresh_date'] = "REFRESH DATE (Next available) ".$response['refresh_date'];
$this->response['type'] = "success";
$this->response['message'] = 'Fetched data successfully.';
}
}
}
private function getCreditReportRefreshButtonContent($inputData){
$auth_user = auth()->user();
$response ='';
/*$creditReportDataObj=[];*/
/*$creditReportDataObj['email'] = "stevetest@consumerdirect.com";
$creditReportDataObj['password'] ="123456789";*/
if($auth_user->credit_report_company_type == config('constant.reportType.SMART_CREDIT')){
$response = (new CreditReportService())->getSmartCreditRefreshButtonContent($auth_user['email'],customDecrypt($auth_user['password']));
}else if($auth_user->credit_report_company_type == config('constant.reportType.IDENTITY_IQ')){
$response = (new CreditReportService())->getIdentityRefreshButtonContent($auth_user['email'], customDecrypt($auth_user['password']), $auth_user->ssn);
}
$this->response['message'] = "";
if(!empty($response)){
$this->response['status'] = false;
$this->response['code'] = config('constant.API_SUCCESS_CODE');
if( strtoupper($response) == 'DONE'){
$this->response['status'] = true;
$this->response['message'] = "Congratulations! Your Refresh is Complete. Please click the Import to get Your Most Recent Report Now";
}
if(strtoupper($response) == "ERROR" || strtoupper($response) == "TIME_OUT" ) {
$this->response['message'] = 'Not found';
}
if(strtoupper($response) == "BUTTON_NOT_FOUND"){
$this->response['message'] = $response;
}
}
}
public function getTrainingVideo(Request $request)
{
$inputData['action']="GET_TRAINING_VIDEO";
$sectionName=getSectionById($request['section_id']);
$video= (new VideoSetting())->getVideoBySectionId($request['section_id']);
if(!empty($video))
{
$this->response['status'] = true;
$this->response['data']['video'] =$video;
$this->response['data']['section_name'] =$sectionName;
$this->response['message'] = "Training Video fetched successfully";
$this->response['code'] = config('constant.API_SUCCESS_CODE');
}
else {
$this->response['data'] = ['section_name' => $sectionName];
}
appLog($this->logDataCreate($inputData['action'],getModelDataMasking($inputData),$this->response['message'],$this->response['data']['html'] ?? "",$this->response['code'] ?? ""));
return response()->json($this->response,200);
}
private function deleteClient($id,$delete_type)
{
$action='DELETE_CLIENT';
$message = 'Client has deleted successfully';
if($delete_type == 'employee')
{
$action='DELETE_EMPLOYEE';
$message = 'Employee has deleted successfully';
}
if($id>0) {
$returnData=(new User())->deleteUser($id);
if($returnData) {
$this->response['message'] = $message;
$this->response['code'] = config('constant.API_SUCCESS_CODE');
$this->response['type'] = 'success';
$this->response['status'] = true;
}
}
return response()->json($this->response,200);
}
private function getUserPermission($id)
{
$action='GET_USER_PERMISSION';
$permitted_module= (new Permission())->getPermittedSubmoduleIdListByUserId($id);
if($permitted_module) {
$this->response['message'] = 'fetch data successfully';
$this->response['code'] = config('constant.API_SUCCESS_CODE');
$this->response['type'] = 'success';
$this->response['status'] = true;
$this->response['data']=$permitted_module;
}
return response()->json($this->response,200);
}
private function customer_subscription_status_submit($inputData){
$responseData=[];
$responseData['status_code'] = config('constant.API_SUCCESS_CODE');
if($responseData['status_code'] == config('constant.API_SUCCESS_CODE')){
Auth::user()->update([
'subscription_status' => 0,
'status' => 2,
'account_cancel_datetime' => getCurrentDateTime()
]);
$this->response['status'] = true;
$this->response['code'] = config('constant.API_SUCCESS_CODE');
$this->response['message'] = "Account has been cancelled successfully";
$this->response['type'] = "success";
}else{
$this->response['status'] = false;
$this->response['code'] = config('constant.API_FAILED_CODE');
$this->response['message'] = "Account has not been cancelled. Please contact with support.";
$this->response['type'] = "error";
}
}
private function logDataCreate($action,$request,$message,$response,$code)
{
$logData=[];
$logData['action'] = $action;
$logData['data']['request'] = $request;
$logData['data']['message'] = $message;
$logData['data']['response'] = $response;
$logData['data']['code'] = $code;
return $logData;
}
private function cancelAccountMail($inputData)
{
$data['email'] = $inputData['email'];
$data['email_body'] = $inputData['name'];
$data['email_subject'] = "Cancel Account From Credit Counsel Elite";
$from = null;
$attachment = null;
$result = (new User())->getUserListByType(1);
(new Email())->send($data, $data['email_subject'], $from, $attachment, 'email.account_closing_letter', $data['email']);
(new Email())->send($data, $data['email_subject'], $from, $attachment, 'email.account_closing_admin_letter', $result[0]['email']);
}
private function getSubscriptionStatusCreditReportProvider($inputData){
$this->response = (new CreditReportService())->validateUserInCreditReportProvider($inputData);
}
private function generateHtml($json_data){
$data_set = (new SmartCreditJsonToHtml())->generateHtml($json_data);
$html = '';
if($data_set != null) {
$creditScore = $data_set['creditScore'];
$personal_infos = $data_set['personal_infos'];
$consumer_statement_data_set = $data_set['consumer_statement_data_set'];
$summary_info_data_set = $data_set['summary_info_data_set'];
$creditor_contact_data_set = $data_set['creditor_contact_data_set'];
$inquiries_data_set = $data_set['inquiries_data_set'];
$account_history_data_set = $data_set['account_history_data_set'];
$html = view('partials.credit_report.main_report', compact('creditScore', 'personal_infos', 'consumer_statement_data_set', 'summary_info_data_set', 'creditor_contact_data_set', 'inquiries_data_set', 'account_history_data_set'))->render();
}
return $html;
}
private function deleteDocFile($inputData)
{
$media_file = json_decode($inputData['userData'],true);
$postData['user_id']=auth()->user()->id;
$returnData = (new Uploadmedia())->deleteById($media_file['id']);
if($returnData) {
$file_path = config('constant.UPLOAD_MEDIA_PATH').DIRECTORY_SEPARATOR.auth()->user()->id;
deleteFile($file_path.DIRECTORY_SEPARATOR.$media_file['image_path']);
$this->response['message'] = 'File has been deleted successfully';
$this->response['code'] = config('constant.API_SUCCESS_CODE');
$this->response['type'] = 'success';
$this->response['status'] = true;
$this->response['data']['html'] = $returnData;
}
}
private function closeSupportTicket($inputData)
{
$returnData = (new Support())->updateSupport($inputData['userData']);
if($returnData) {
$this->response['message'] = 'Ticket has been closed successfully';
$this->response['code'] = config('constant.API_SUCCESS_CODE');
$this->response['type'] = 'success';
$this->response['status'] = true;
$this->response['data']['html'] = $returnData;
}
}
private function sendReminder($inputData){
$from = null;
$attachment = null;
$supports = (new Support())->getSupportId($inputData['supportId']);
if(!empty($supports)) {
$data['email'] = $supports->email;
$data['email_body'] = "Please check your message.Ticket ID ".$supports->id;
$data['email_subject'] = "You have a message.";
(new Email())->send($data, $data['email_subject'], $from, $attachment, 'email.reminderletter', $data['email']);
$this->response['message'] = 'Reminder has been sent to member successfully';
$this->response['code'] = config('constant.API_SUCCESS_CODE');
$this->response['type'] = 'success';
$this->response['status'] = true;
}
}
}

View File

@@ -0,0 +1,130 @@
<?php
namespace App\Http\Controllers;
use App\Http\Requests\LoginRequest;
use App\Models\CreditreportProvider;
use App\Models\Permission;
use App\Models\Support;
use App\Models\User;
use App\Models\VideoSetting;
use Illuminate\Support\Facades\Auth;
class AuthController extends Controller
{
private $message;
private $code;
private $data;
public function __construct()
{
$this->middleware('guest')->except([
'userLogout',
'showRegisterForm',
'register',
'authRedirect'
]);
$this->message = 'Fail';
$this->code = config('constant.API_FAILED_CODE');
$this->data=[];
}
public function authRedirect(){
if(auth()->check()){
$user_type = auth()->user()->user_type;
if($user_type == 0){
return redirect(route('show.manage.clients'));
}elseif ($user_type == 2){
$permissions_route_list = getSession('permissions_route_list');
return redirect(route($permissions_route_list[0]));
}else {
return redirect(route('get.clients'));
}
}
return redirect(route('login'));
}
public function showLoginForm(){
return view('auth.login');
}
public function login(LoginRequest $request){
$inputData = $request->only(['email','password']);
$action='USER_LOGIN';
$userObjData = (new User())->getAuthenticateUser($inputData['email'],$inputData['password']);
if(!empty($userObjData)){
Auth::loginUsingId($userObjData->id);
if($userObjData->user_type == 0)
{
$days = getDateDifference($userObjData->last_import_date,'day');
setSession('login',1);
if($days >= config('constant.PACKAGE_INTERVAL_DAY')){
setSession('eligible_for_import',1);
$userObjData->is_import = config('constant.IMPORT_REPORT_STATUS.ELIGIBLE');
// $userObjData->wave = ($userObjData->wave +1);
// $userObjData->last_import_date = getCurrentDateTime();
$userObjData->save();
}
getUserImagesAndDoc($userObjData->id);
$this->setTrainingVideoLink();
$this->setReportProviderLink();
$inputData['id'] = $userObjData->id;
$inputData['user_type'] = 0;
$this->setSupport($inputData);
return redirect(route('show.manage.clients'));
}else if($userObjData->user_type == 2){
$permissions_route_list = (new Permission())->getRouteNameListByUserId($userObjData->id);
setSession('permissions_route_list',$permissions_route_list);
$inputData['id'] = $userObjData->id;
$inputData['user_type'] = 1;
$this->setSupport($inputData);
return redirect(route($permissions_route_list[0]));
}
else{
$inputData['id'] = $userObjData->id;
$inputData['user_type'] = 1;
$this->setSupport($inputData);
return redirect(route('get.clients'));
}
}
return back()->withErrors(['message'=>'Invalid email or password']);
}
public function userLogout(){
auth()->logout();
return redirect(route('login'));
}
private function setTrainingVideoLink(){
$key = 'training_video_link';
$inputData['is_welcome_video'] = 1 ;
unsetCache($key);
if(empty(getCache($key))){
$training_video = (new VideoSetting())->getVideos($inputData)->pluck('link','id');
if(!empty($training_video)) {
setCache($key, $training_video);
}
}
}
private function setReportProviderLink(){
$key = 'credit_report_provider_link';
unsetCache($key);
if(empty(getCache($key))){
$report_provider = (new CreditreportProvider())->getReportProviders();
if(!empty($report_provider)) {
setCache($key, $report_provider);
}
}
}
private function setSupport($inputData)
{
// $support_data = (new Support())->getSupport($inputData);
// setSession('new_ticket',$support_data->count());
$support_data = (new Support())->getNotifcation($inputData['id'],$inputData['user_type'])->toArray();
setSession('new_ticket',$support_data);
}
}

View File

@@ -0,0 +1,483 @@
<?php
namespace App\Http\Controllers;
use App\Models\Content;
use App\Utility\ActionLogCreate;
use Illuminate\Http\Request;
class BasicController extends Controller
{
public function termAndService(Request $request)
{
if($request->isMethod('post'))
{
$action="TERMS AND SERVICE CREATE";
$file_path = config('constant.CONTENT_DIR') . DIRECTORY_SEPARATOR ;
$file_name = "terms_and_service.html";
$inputData=['id'=>$request['id'],'terms_service'=>$file_path.$file_name];
uploadHTML($file_path, $file_name, $request['body']);
$returnData=(new Content())->insert($inputData);
ActionLogCreate::logDataCreate($action,$request->all(),$returnData['message'],$returnData['data'],'');
return back()->with('success',$returnData['message']);
}
$content=$this->getTermsAndCondition();
return view('basic.terms_and_service_entry',compact('content'));
}
public function termsAndCondition()
{
$content=$this->getTermsAndCondition();
return view('basic.terms_and_condition',compact('content'));
}
private function getTermsAndCondition()
{
$content=(new Content())->get();
if(!empty($content)) {
$content['terms_service'] = getFile($content['terms_service']);
$content['title'] = 'terms and service';
}
return $content;
}
private function generateHtml()
{
$path = public_path('report/credit_report.json');
// $path = public_path('report/credit_report2.json');
$json_data = json_decode(file_get_contents($path),true);
$json_data = $json_data['BundleComponents']['BundleComponent'];
$json_data = $json_data[6]['TrueLinkCreditReportType'];
$borrower_info = $json_data['Borrower'];
$credit_scores = $borrower_info['CreditScore'];
$creditScore = [
'title' => 'Vantage Score® 3.0 credit score',
'TransUnion'=> $credit_scores[0]['riskScore'],
'Experian'=> $credit_scores[1]['riskScore'],
'Equifax'=> $credit_scores[2]['riskScore'],
];
$personal_infos = $this->personal_information_data_binding($borrower_info);
$summary_info_data_set = $this->summary_info_data_binding($json_data);
$creditor_contact_data_set = $this->creditor_contacts_data_binding($json_data);
$inquiries_data_set = $this->inquiries_data_binding($json_data);
$account_history_data_set = $this->account_history_data_binding($json_data['TradeLinePartition']);
// $html = view('partials.credit_report.personal_info', compact('personal_infos'))->render();
// $html = view('partials.credit_report.summary',compact('summary_info_data_set'))->render();
// $html = view('partials.credit_report.creditor_contact',compact('creditor_contact_data_set'))->render();
// $html = view('partials.credit_report.inquiries',compact('inquiries_data_set'))->render();
$html = view('partials.credit_report.main_report',compact('creditScore','personal_infos','summary_info_data_set','creditor_contact_data_set','inquiries_data_set','account_history_data_set'))->render();
// dd($html);
echo $html;exit;
}
private function personal_information_data_binding($borrower_info)
{
$personal_info_employer = [];
$personal_info_birth = [];
$personal_info_borrowerName = [];
$personal_info_borrowerAddress = [];
$personal_info_previousAddress = [];
$personal_info_creditScore = [];
if(isset($borrower_info['Employer']))
{
$personal_info_employer = $borrower_info['Employer'];
}
if(isset($borrower_info['Birth']))
{
$personal_info_birth = $borrower_info['Birth'];
}
if(isset($borrower_info['BorrowerName']))
{
$personal_info_borrowerName = $borrower_info['BorrowerName'];
}
if(isset($borrower_info['BorrowerAddress']))
{
$personal_info_borrowerAddress = $borrower_info['BorrowerAddress'];
}
if(isset($borrower_info['PreviousAddress']))
{
$personal_info_previousAddress = $borrower_info['PreviousAddress'];
}
if(isset($borrower_info['CreditScore']))
{
$personal_info_creditScore = $borrower_info['CreditScore'];
}
$personal_info_data_set = [
'CREDIT_REPORT_DATE' =>[
'title' => 'CREDIT REPORT DATE',
'TransUnion'=> array_filter($personal_info_creditScore,function ($item){
if($item['Source']['Bureau']['symbol'] == 'TUC'){
return $item;
}
}),
'Experian'=>array_filter($personal_info_creditScore,function ($item){
if($item['Source']['Bureau']['symbol'] == 'EXP'){
return $item;
}
}),
'Equifax'=>array_filter($personal_info_creditScore,function ($item){
if($item['Source']['Bureau']['symbol'] == 'EQF'){
return $item;
}
}),
'css_class_1'=>'crLightTableBackground',
'css_class_2'=>'crLightTableBackground'
],
'NAME' =>[
'title' => 'NAME',
'TransUnion'=> array_filter($personal_info_borrowerName,function ($item){
if($item['Source']['Bureau']['symbol'] == 'TUC'){
return $item;
}
}),
'Experian'=>array_filter($personal_info_borrowerName,function ($item){
if($item['Source']['Bureau']['symbol'] == 'EXP'){
return $item;
}
}),
'Equifax'=>array_filter($personal_info_borrowerName,function ($item){
if($item['Source']['Bureau']['symbol'] == 'EQF'){
return $item;
}
}),
'css_class_1'=>'crTableHeader',
'css_class_2'=>'crTableHeader'
],
'ALSO_KNOWN_AS' =>[
'title' => 'ALSO KNOWN AS',
'TransUnion'=>[],
'Experian'=>[],
'Equifax'=>[],
'css_class_1'=>'crTradelineHeader',
'css_class_2'=>'crTableBackground'
],
'DATE_OF_BIRTH'=>[
'title' => 'DATE OF BIRTH',
'TransUnion'=> array_filter($personal_info_birth,function ($item){
if($item['Source']['Bureau']['symbol'] == 'TUC'){
return $item;
}
}),
'Experian'=>array_filter($personal_info_birth,function ($item){
if($item['Source']['Bureau']['symbol'] == 'EXP'){
return $item;
}
}),
'Equifax'=>array_filter($personal_info_birth,function ($item){
if($item['Source']['Bureau']['symbol'] == 'EQF'){
return $item;
}
}),
'css_class_1'=>'crTableBackground',
'css_class_2'=>'crTradelineHeader'
],
'CURRENT_ADDRESS'=>[
'title' => 'CURRENT ADDRESS',
'TransUnion'=> array_filter($personal_info_borrowerAddress,function ($item){
if($item['Source']['Bureau']['symbol'] == 'TUC'){
return $item;
}
}),
'Experian'=>array_filter($personal_info_borrowerAddress,function ($item){
if($item['Source']['Bureau']['symbol'] == 'EXP'){
return $item;
}
}),
'Equifax'=>array_filter($personal_info_borrowerAddress,function ($item){
if($item['Source']['Bureau']['symbol'] == 'EQF'){
return $item;
}
}),
'css_class_1'=>'crLightTableBackground',
'css_class_2'=>'crLightTableBackground'
],
'PREVIOUS_ADDRESS'=>[
'title' => 'PREVIOUS ADDRESS',
'TransUnion'=> array_filter($personal_info_previousAddress,function ($item){
if($item['Source']['Bureau']['symbol'] == 'TUC'){
return $item;
}
}),
'Experian'=>array_filter($personal_info_previousAddress,function ($item){
if($item['Source']['Bureau']['symbol'] == 'EXP'){
return $item;
}
}),
'Equifax'=>array_filter($personal_info_previousAddress,function ($item){
if($item['Source']['Bureau']['symbol'] == 'EQF'){
return $item;
}
}),
'css_class_1'=>'crLightTableBackground',
'css_class_2'=>'crLightTableBackground'
],
'EMPLOYER'=>[
'title' => 'EMPLOYER',
'TransUnion'=> array_filter($personal_info_employer,function ($item){
if($item['Source']['Bureau']['symbol'] == 'TUC'){
return $item;
}
}),
'Experian'=>array_filter($personal_info_employer,function ($item){
if($item['Source']['Bureau']['symbol'] == 'EXP'){
return $item;
}
}),
'Equifax'=>array_filter($personal_info_employer,function ($item){
if($item['Source']['Bureau']['symbol'] == 'EQF'){
return $item;
}
}),
'css_class_1'=>'crTradelineHeader',
'css_class_2'=>'crTradelineHeader'
],
];
return $personal_info_data_set;
}
private function inquiries_data_binding($inquiryPartition)
{
$inquiries_info = [];
if(isset($inquiryPartition['InquiryPartition']))
{
$inquiries_info = $inquiryPartition['InquiryPartition'];
if(count($inquiries_info)== 1) {
$inquiries_info['Inquiry'] = $inquiryPartition['InquiryPartition'];
}
}
return $inquiries_info;
}
private function creditor_contacts_data_binding($creditor_contact)
{
$creditor_contacts_info = [];
if(isset($creditor_contact['Subscriber']))
{
$creditor_contacts_info = $creditor_contact['Subscriber'];
}
return $creditor_contacts_info;
}
private function summary_info_data_binding($summary)
{
$summary_info = [];
if(isset($summary['Summary']))
{
$summary_info = $summary['Summary'];
}
$summary_info_data = [
'TOTAL_ACCOUNTS' => [
'title' => 'TOTAL ACCOUNTS',
'TransUnion'=> $summary_info['TradelineSummary']['TransUnion']['TotalAccounts'],
'Experian'=> $summary_info['TradelineSummary']['Experian']['TotalAccounts'],
'Equifax'=> $summary_info['TradelineSummary']['Equifax']['TotalAccounts'],
],
'OPEN_ACCOUNTS' => [
'title' => 'OPEN ACCOUNTS',
'TransUnion'=> $summary_info['TradelineSummary']['TransUnion']['OpenAccounts'],
'Experian'=> $summary_info['TradelineSummary']['Experian']['OpenAccounts'],
'Equifax'=> $summary_info['TradelineSummary']['Equifax']['OpenAccounts'],
],
'CLOSED_ACCOUNTS' =>[
'title' => 'CLOSED ACCOUNTS',
'TransUnion'=> $summary_info['TradelineSummary']['TransUnion']['CloseAccounts'],
'Experian'=> $summary_info['TradelineSummary']['Experian']['CloseAccounts'],
'Equifax'=> $summary_info['TradelineSummary']['Equifax']['CloseAccounts'],
],
'DELINQUENT'=>[
'title' => 'DELINQUENT',
'TransUnion'=> $summary_info['TradelineSummary']['TransUnion']['DelinquentAccounts'],
'Experian'=> $summary_info['TradelineSummary']['Experian']['DelinquentAccounts'],
'Equifax'=> $summary_info['TradelineSummary']['Equifax']['DelinquentAccounts'],
],
'DEROGATORY'=>[
'title' => 'DEROGATORY',
'TransUnion'=> $summary_info['TradelineSummary']['TransUnion']['DerogatoryAccounts'],
'Experian'=> $summary_info['TradelineSummary']['Experian']['DerogatoryAccounts'],
'Equifax'=> '--',
],
'BALANCES'=>[
'title' => 'BALANCES',
'TransUnion'=> '$'.$summary_info['TradelineSummary']['TransUnion']['TotalBalances'],
'Experian'=>'$'. $summary_info['TradelineSummary']['Experian']['TotalBalances'],
'Equifax'=>'$'. $summary_info['TradelineSummary']['Equifax']['TotalBalances'],
],
'PAYMENTS'=>[
'title' => 'PAYMENTS',
'TransUnion'=>'$'. $summary_info['TradelineSummary']['TransUnion']['TotalMonthlyPayments'],
'Experian'=>'$'. $summary_info['TradelineSummary']['Experian']['TotalMonthlyPayments'],
'Equifax'=>'$'. $summary_info['TradelineSummary']['Equifax']['TotalMonthlyPayments'],
],
'PUBLIC_RECORDS'=>[
'title' => 'PUBLIC RECORDS',
'TransUnion'=> $summary_info['PublicRecordSummary']['TransUnion']['NumberOfRecords'],
'Experian'=> $summary_info['PublicRecordSummary']['Experian']['NumberOfRecords'],
'Equifax'=> $summary_info['PublicRecordSummary']['Equifax']['NumberOfRecords'],
],
'INQUIRIES'=>[
'title' => 'INQUIRIES (2 years)',
'TransUnion'=> $summary_info['InquirySummary']['TransUnion']['NumberInLast2Years'],
'Experian'=> $summary_info['InquirySummary']['Experian']['NumberInLast2Years'],
'Equifax'=> $summary_info['InquirySummary']['Equifax']['NumberInLast2Years'],
]
];
return $summary_info_data;
}
private function account_history_data_binding($account_historys)
{
$account_history_data = [];
foreach ($account_historys as $account_history )
{
$tradelines = $account_history['Tradeline'];
if(isset($tradelines['subscriberCode']) && isset($tradelines['accountNumber'])
&& isset($tradelines['creditorName'])){
$tradelines = [ $tradelines ];
}
$data = $this->common_data_binding($tradelines);
$account_history_data[$tradelines[0]['creditorName']] = ['key_data'=>$this->sub_account_history_data_bindings(),'data'=> $data];
}
// dd($account_history_data);
return $account_history_data;
}
private function sub_account_history_data_bindings()
{
$return_data = [
'ACCOUNT'=> [
'title' => 'Account #',
],
'HIGH_BALANCE' => [
'title' => 'High Balance',
],
'LAST_VERIFIED' =>[
'title' => 'Last Verified',
],
'DATE_OF_LAST_ACTIVITY' =>[
'title' => 'Date of Last Activity',
],
'DATE_REPORTED'=>[
'title' => 'Date Reported',
],
'DATE_OPENED'=>[
'title' => 'Date Opened',
],
'BALANCE_OWED'=>[
'title' => 'Balance Owed',
],
'CLOSED_DATE'=>[
'title' => 'Closed Date',
],
'ACCOUNT_RATING'=>[
'title' => 'Account Rating',
],
'ACCOUNT_DESCRIPTION'=>[
'title' => 'Account Description',
],
'DISPUTE_STATUS'=>[
'title' => 'Dispute Status',
],
'CREDITOR_TYPE'=> [
'title' => 'Creditor Type',
],
'ACCOUNT_STATUS'=>[
'title' => 'Account Status',
],
'PAYMENT_STATUS'=> [
'title' => 'Payment Status',
],
'CREDITOR_REMARKS'=>[
'title' => 'Creditor Remarks',
],
'PAYMENT_AMOUNT'=> [
'title' => 'Payment Amount',
],
'LAST_PAYMENT'=>[
'title' => 'Last Payment',
],
'TERM_LENGTH'=>[
'title' => 'Term Length',
],
'PAST_DUE_AMOUNT'=>[
'title' => 'Past Due Amount',
],
'ACCOUNT_TYPE'=>[
'title' => 'Account Type',
],
'PAYMENT_FREQUENCY'=>[
'title' => 'Payment Frequency',
],
'CREDIT_LIMIT'=>[
'title' => 'Credit Limit',
],
];
return $return_data;
}
private function common_data_binding($data)
{
$data_set = [
'TransUnion'=> array_filter($data,function ($item){
if($item['Source']['Bureau']['symbol'] == 'TUC'){
return $item;
}
}),
'Experian'=>array_filter($data,function ($item){
if($item['Source']['Bureau']['symbol'] == 'EXP'){
return $item;
}
}),
'Equifax'=>array_filter($data,function ($item){
if($item['Source']['Bureau']['symbol'] == 'EQF'){
return $item;
}
}),
];
return $data_set;
}
}

View File

@@ -0,0 +1,13 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;
class Controller extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
}

View File

@@ -0,0 +1,159 @@
<?php
namespace App\Http\Controllers;
use App\Models\UserWave;
use App\Models\WaveCycle;
use App\Services\SmartCreditJsonToHtml;
use App\Traits\ApiResponseTrait;
use App\Services\CreditReportService;
use App\Utility\ActionLogCreate;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class CreditReportController extends Controller
{
use ApiResponseTrait;
private $message;
private $code;
private $data;
private $credit_report_type;
private $user_id;
private $wave;
private $last_import_date;
private $type;
private $ssn;
public function __construct()
{
$this->message = 'Fail';
$this->code = config('constant.API_FAILED_CODE');
$this->data=[];
$this->type='error';
}
public function setAuthUser(){
$auth_user = auth()->user();
$this->user_id = $auth_user->id;
$this->credit_report_type = $auth_user->credit_report_company_type;
$this->wave = $auth_user->wave;
$this->last_import_date = $auth_user->last_import_date;
$this->ssn = $auth_user->ssn;
}
public function getCreditReport(Request $request)
{
$this->setAuthUser();
$inputData = $request->all();
$response['status'] = false;
$action='GET_CREDIT_REPORT';
$this->message='Can not fetch Credit Report.';
if($inputData['action'] == "GET_CREDIT_REPORT"){
$creditReport = (new CreditReportService())->getUpdatedReport($this->user_id,$this->credit_report_type,$this->ssn);
if($creditReport['status']){
$response['status'] = true;
// if(config('app.SMART_CREDIT_REPORT_BY_JSON') == '1' && $this->credit_report_type == config('constant.reportType.SMART_CREDIT')) {
// $creditReport['html'] = $this->generateHtml($creditReport['html']);
// }
$response['data'] = $creditReport['html'];
$this->type='success';
$this->message='Credit Report is fetched successfully.';
}
}
$requestData=[$this->user_id,$this->credit_report_type];
ActionLogCreate::logDataCreate($action,$requestData,$this->message,$response['status'],$this->code);
return response()->json($response,200);
}
public function uploadCreditReport(Request $request)
{
$this->setAuthUser();
$action='UPLOAD_CREDIT_REPORT';
$this->message='Credit Report uploaded Fail.';
$inputData = $request->all();
$inputData['user_id']=$this->user_id;
$inputData['report_type']=$this->credit_report_type;
$creditReportResponse['status']=false;
if(!empty($inputData['credithtml'])) {
$creditReportResponse = (new CreditReportService())->uploadCreditReport($inputData);
if($creditReportResponse['status'])
{
if(getSession('video_first_time'))
{
unSetSession('video_first_time');
setSession('view_video_first_time',true);
}
$this->updateUserWave();
$this->type='success';
$this->message='Credit Report is uploaded successfully';
$this->code=config('constant.API_SUCCESS_CODE');
}
$this->data=$creditReportResponse;
}
$logRequestData=[$this->user_id,$this->credit_report_type];
$logResponseData=[$this->code,$this->message];
ActionLogCreate::logDataCreate($action,$logRequestData,$this->message,$logResponseData,$this->code);
return back()->with([$this->type => $this->message]);
}
private function updateUserWave()
{
$this->setAuthUser();
$days = getDateDifference($this->last_import_date,'day');
$inputData['user_id'] = $this->user_id;
if($days >= config('constant.PACKAGE_INTERVAL_DAY')){
if($this->wave == config('constant.MAX_WAVE'))
{
(new WaveCycle())->insertUserWaveCycle($inputData);
}
$this->wave = $this->getUserWave();
$this->last_import_date = getCurrentDateTime();
}
$inputData['wave'] = $this->wave;
$inputData['last_import_date'] = $this->last_import_date;
Auth::user()->update([
'is_import'=>config('constant.IMPORT_REPORT_STATUS.NOT_ELIGIBLE'),
'wave'=>$inputData['wave'],
'last_import_date'=> $inputData['last_import_date']
]);
$userwave= (new UserWave())->insertUserWave($inputData);
ActionLogCreate::logDataCreate('USER_WAVE_CREATE',$inputData,$userwave['message'],$userwave['data'],config('constant.API_SUCCESS_CODE'));
return $userwave;
}
private function getUserWave()
{
$currentWave = 1;
if($this->wave < config('constant.MAX_WAVE')){
$currentWave = $this->wave + 1;
}
return $currentWave ;
}
private function generateHtml($json_data):string{
$data_set = (new SmartCreditJsonToHtml())->generateHtml($json_data);
$html = '';
if($data_set != null) {
$creditScore = $data_set['creditScore'];
$personal_infos = $data_set['personal_infos'];
$consumer_statement_data_set = $data_set['consumer_statement_data_set'];
$summary_info_data_set = $data_set['summary_info_data_set'];
$creditor_contact_data_set = $data_set['creditor_contact_data_set'];
$inquiries_data_set = $data_set['inquiries_data_set'];
$account_history_data_set = $data_set['account_history_data_set'];
$html = view('partials.credit_report.main_report', compact('creditScore', 'personal_infos', 'consumer_statement_data_set', 'summary_info_data_set', 'creditor_contact_data_set', 'inquiries_data_set', 'account_history_data_set'))->render();
}
return $html;
}
}

View File

@@ -0,0 +1,92 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\CreditreportProvider;
use App\Utility\ActionLogCreate;
use App\Http\Requests\CreditReportProviderRequest;
class CreditReportProviderController extends Controller
{
private $message;
private $code;
private $data;
private $action;
private $type;
public function __construct()
{
$this->action='';
$this->type='error';
$this->message = 'Fail';
$this->code = config('constant.API_FAILED_CODE');
$this->data=[];
}
public function index(Request $request)
{
$providers=(new CreditreportProvider())->getReportProviders();
return view('report_provider.provider_add_edit_delete',compact('providers'));
}
public function createReportProvider(CreditReportProviderRequest $request)
{
$this->action='INSERT_CREDIT_REPORT_PROVIDER';
$this->message='can not save data.';
$inputData = $request->only(['source_type','link']);
$inputData['company_type'] = $inputData['source_type'];
$returnData = (new CreditreportProvider())->insertReportProvider($inputData);
if (!empty($returnData)) {
$this->message='Successfully Saved';
$this->code=config('constant.API_SUCCESS_CODE');
$this->type='success';
}
ActionLogCreate::logDataCreate( $this->action,$request->all(),$this->message,$returnData,$this->code);
return back()->with($this->type, $this->message);
}
public function editReportProvider(Request $request)
{
$validated = $request->validate([
'edit_source_type' => 'required',
'edit_link' => 'required|regex:'.config('constant.REPORT_PROVIDER_LINK_VALIDATION'),
]);
$this->action='EDIT_CREDIT_REPORT_PROVIDER';
$this->message='can not save data.';
$inputData = $request->only(['edit_source_type','edit_link']);
$inputData['company_type'] = $inputData['edit_source_type'];
$returnData = (new CreditreportProvider())->updateReportProvider($inputData);
if (!empty($returnData)) {
$this->message='Successfully Updated';
$this->code=config('constant.API_SUCCESS_CODE');
$this->type='success';
}
ActionLogCreate::logDataCreate( $this->action,$request->all(),$this->message,$returnData,$this->code);
return back()->with($this->type, $this->message);
}
public function deleteReportProvider(Request $request)
{
$request->validate([
'delete_source_type' => 'required|gt:0',
]);
$this->action='DELETE_TRAINING_VIDEO';
$this->message='can not delete data.';
$inputData = $request->only(['delete_source_type']);
if($inputData['delete_source_type']>0) {
$returnData = (new CreditreportProvider())->deleteReportProvider($inputData);
if (!empty($returnData)) {
$this->message='Successfully Deleted';
$this->code=config('constant.API_SUCCESS_CODE');
$this->type='success';
}
ActionLogCreate::logDataCreate($this->action,$request->all(),$this->message,$returnData,$this->code);
}
return back()->with($this->type, $this->message);
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,43 @@
<?php
namespace App\Http\Controllers;
use App\Models\IqCallHistory;
use App\Services\ViewExport;
use Illuminate\Http\Request;
use Maatwebsite\Excel\Facades\Excel;
class HistoryController extends Controller
{
public function __construct()
{
}
public function Index(Request $request)
{
$items = empty($request->pageLimit) ? config('constant.PAGINATION_LIMIT'):$request->pageLimit;
$searchData=[
'pageLimit'=>$items,
'status_code'=>$request['status_code'],
'fdate'=>$request['fdate'],
'tdate'=>$request['tdate']
];
$histories =(new IqCallHistory())->getHistories($searchData) ;
if(!empty($request['export']) && $request['export'] == 1)
{
return Excel::download(new ViewExport($histories,'partials.iq_call_histories'), 'IqCallHistories.xlsx');
}
return view('history.list',compact('histories','searchData'));
}
}

View File

@@ -0,0 +1,31 @@
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class ModalController extends Controller
{
public function showModal(Request $request){
$inputData = $request->all();
if( $inputData['type'] == 'SUPPORT_MODAL_VIEW'){
return view('partials.modal.support_modal');
}
if($inputData['type'] == 'PROFILE_IMAGE_MODAL_VIEW'){
return view('partials.modal.image_view_modal');
}
if($inputData['type'] == 'FIRST_TIME_LOGIN_MODAL_VIEW'){
return view('partials.modal.first_time_login_modal');
}
if($inputData['type'] == 'UPLOAD_DOC_MODAL'){
return view('partials.modal.upload_doc_modal');
}
if($inputData['type'] == 'COMMON_MODAL'){
return view('partials.modal.common_modal',compact('inputData'));
}
}
}

View File

@@ -0,0 +1,226 @@
<?php
namespace App\Http\Controllers;
use App\Models\Recurring;
use App\Models\Sale;
use App\Models\User;
use App\Services\Package;
use App\Services\Payment\GateWay;
use App\Services\Payment\Payment;
use App\Services\PaymentService;
use Illuminate\Support\Facades\Auth;
use App\Http\Requests\PaymentSettingRequest;
use App\Utility\ActionLogCreate;
class PaymentController extends Controller
{
public function paymentSetting(PaymentSettingRequest $request)
{
$message = "Can not update card number.";
$type = 'error';
$status_code = config('constant.API_FAILED_CODE');
$inputData = $request->all();
$inputData['save_card'] = request('save_card', 0);
$inputData['clear_card'] = request('clear_card', 0);
$action = 'PAYMENT_SETTING';
$inputData['user'] = auth()->user();
$inputData['ip'] = request()->getClientIp(true);
$requestData = $this->prepareData($inputData);
try {
$findData['user_id'] = $requestData['user_id'];
$findData['status'] = 1;
$recurringData = (new Recurring())->getRecurringByUserId($findData);
if(!empty($recurringData)) {
// $package = new Package();
// $package->makePayments($requestData);
$deleteRecurringData['email'] = $requestData['email'];
$deleteRecurringData['subscription_id'] = $recurringData['subscription_id'];
$deleteRecurringResponse = (new Package())->deleteRecurringPackage($deleteRecurringData);
if ($deleteRecurringResponse['status_code'] == config('constant.API_SUCCESS_CODE')) {
$updateRecurring['status'] = 2;
$recurringData->update($updateRecurring);
$recurringResponse = (new Package())->recurringPackage($requestData);
if($recurringResponse['status_code'] == config('constant.API_SUCCESS_CODE')) {
Auth::user()->update([
'subscription_status' => config('constant.SUBSCRIPTION_STATUS.SUBSCRIBED'),
'last_payment_date' => getCurrentDateTime(),
'user_access_end_date' => getDateAfterSpicificDay(getCurrentDateTime(),config('constant.PAYMENT_INTERVAL_DAY'))
]);
$message = "Card number has been updated successful.";
$status_code = config('constant.API_SUCCESS_CODE');
$type = 'success';
}
}
}else{
$onetimePayment = (new PaymentService())->makePayment($requestData);
if($onetimePayment['status']) {
// for recurring
$recurringResponse = (new Package())->recurringPackage($requestData);
$this->updateUser($requestData);
$message = "Payment and Card number has been updated successful.";
$status_code = config('constant.API_SUCCESS_CODE');
$type = 'success';
}
}
}catch (\Exception $ex){
$message = "Can not update card number.";
$status_code = config('constant.API_FAILED_CODE');
}
if ($status_code == config('constant.API_SUCCESS_CODE')) {
$this->updateCookies($inputData);
$message = "Card number has been updated successful.";
$type = 'success';
}
ActionLogCreate::logDataCreate($action, getModelDataMasking($inputData), $message, "", $status_code);
return back()->with([$type => $message]);
}
public function subscriptionUpdateByCronJob()
{
$recurringData = (new Recurring())->getRecurringDataForScheduler();
if(!empty($recurringData)) {
foreach ($recurringData as $recurring) {
$logData['action_by_subscription_id_start'] = "CLIENT_SUBSCRIPTION_UPDATE_START";
$paymentData = [];
$paymentData['subscription_id'] = $recurring['subscription_id'];
$response = (new Payment(GateWay::getGateWayInstance(config('constant.PAYMENT_GATEWAY.NMI')), $paymentData))->getSubscriptionInfoBySubscriptionId();
if (!empty($response['data']) && array_key_exists(0,$response['data'])) {
$search_data_by_date = [];
$current_date = getCurrentDate();
// $current_date ='2023-03-02';
foreach ($response['data'] as $item) {
if($item['condition'] == 'complete' && array_key_exists(0,$item['action']))
{
$dtr = getStringToDateTime($item['action'][0]['date'], 'Y-m-d');
if($dtr >= $current_date)
{
$search_data_by_date = $item;
break;
}
}
}
if(!empty($search_data_by_date)) {
$logData_subscription['action_by_subscription_start'] = "CLIENT_SUBSCRIPTION_START";
// user update
$user_input['last_payment_date'] = getCurrentDateTime();
$user_input['subscription_status'] = config('constant.SUBSCRIPTION_STATUS.SUBSCRIBED');
$user_input['status'] = config('constant.SUBSCRIPTION_STATUS.SUBSCRIBED');
$return_data = (new User())->userupdate($user_input, $recurring['user_id']);
// recurring update
$recurring_input['last_process_date'] = getCurrentDateTime();
$recurring->update($recurring_input);
// sales insert
$salesData['order_id'] = $search_data_by_date['order_id'];
$salesData['cc_number'] = $search_data_by_date['cc_number'];
$salesData['status'] = "1";
$salesData['auth_code'] = '';
$salesData['transaction_id'] = $search_data_by_date['transaction_id'];
$salesData['ip'] = getClientIpAddress();
$salesData['user_id'] = $recurring['user_id'];
$salesData['recurring_id'] = $recurring['id'];
(new Sale())->createSale($salesData);
$logData_subscription['action_by_subscription_end'] = "CLIENT_SUBSCRIPTION_END";
appLog($logData_subscription);
}
}
$logData['status_code'] = $response['status_code'];
$logData['message'] = $response['message'];
$logData['inputData'] = $recurring;
$logData['action_by_subscription_id_end'] = "CLIENT_SUBSCRIPTION_UPDATE_END";
appLog($logData);
}
}
}
private function prepareData($inputData): array
{
$user_info = $inputData['user'];
$amount=0;
$prepareData['user_id'] = $user_info->id;
$prepareData['password']=customDecrypt($user_info->password);
$prepareData['first_name'] = $user_info['first_name'];
$prepareData['last_name'] = $user_info['last_name'];
$prepareData['wave']=$user_info->wave;
$prepareData['last_payment_date']=$user_info->last_payment_date;
$prepareData['company'] = $user_info['company'] ?? config('app.name');
$prepareData['street_no'] = $user_info['street_no'];
$prepareData['street_name'] = $user_info['street_name'];
$prepareData['city'] = $user_info['city'];
$prepareData['state'] = $user_info['state'];
$prepareData['zip_code'] = $user_info['zip_code'];
$prepareData['country'] = $user_info['country'] ?? 'US';
$prepareData['phone'] = $user_info['phone'];
$prepareData['fax'] = $user_info['fax'] ?? "";
$prepareData['email'] = $user_info['email'];
$prepareData['website'] = $user_info['website'] ?? "";
$prepareData['tax'] = 1;
$prepareData['shipping'] = 1;
$prepareData['ponumber'] = "PO1234";
$prepareData['ip'] = $inputData['ip'];
$prepareData['amount'] = "24.97";
$prepareData['card_number'] = $inputData['card_number'];
$prepareData['expiry'] = $inputData['expiry'];
return $prepareData;
}
private function updateCookies($inputData)
{
$user_id = $inputData['user']->id;
if ($inputData['save_card'] == 1) {
setCache('card_' . $user_id, $inputData['card_number']);
setCache('expiration_' . $user_id, $inputData['expiry']);
setCache('cvv_' . $user_id, $inputData['cvv']);
}
if ($inputData['clear_card'] == 1) {
unsetCache('card_' . $user_id);
unsetCache('expiration_' . $user_id);
unsetCache('cvv_' . $user_id);
}
}
private function updateUser($inputData)
{
$updateUserData['is_import'] = 1;
$updateUserData['subscription_status'] = 1;
$updateUserData['wave'] = 1;
$updateUserData['last_payment_date'] = getCurrentDateTime();
$updateUserData['user_access_end_date'] = getDateAfterSpicificDay(getCurrentDateTime(),config('constant.PAYMENT_INTERVAL_DAY'));
(new User())->userupdate($updateUserData,$inputData['user_id']);
}
}

View File

@@ -0,0 +1,576 @@
<?php
namespace App\Http\Controllers;
use App\Http\Requests\AddPackageRequest;
use App\Http\Requests\AddProfileRequest;
use App\Http\Requests\CreateAccountRequest;
use App\Http\Requests\CustomerProfileRequest;
use App\Http\Requests\MakePaymentRequest;
use App\Http\Requests\SetCreditReportRequest;
use App\Http\Requests\EmployeeRegistrationRequest;
use App\Models\Creditreport;
use App\Models\Permission;
use App\Models\SecurityQuestion;
use App\Models\User;
use App\Models\UserIdentityQuestionAnswer;
use App\Models\UserSecurityQuestionAnswer;
use App\Services\CreditReportService;
use App\Services\Package;
use App\Services\Register;
use App\Services\SmartCredit\SmartCredit;
use App\Traits\ApiResponseTrait;
use App\Utility\Email;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;
use App\Http\Requests\ClientRegistration;
class RegisterController extends Controller
{
use ApiResponseTrait;
public $data = [];
public string $message = 'Failed';
public string $status_code = '';
public string $type = 'error';
public string $code = '';
public function __construct()
{
$this->status_code = config('constant.API_FAILED_CODE');
}
public function createAccount(Request $request)
{
return view('client.manual_client_create');
}
public function createManualAccount(ClientRegistration $request)
{
$inputData = $request->all();
$this->code = config('constant.API_FAILED_CODE');
$logData['action'] = "CREATE_ACCOUNT_MANUALLY";
$last_payment_date = getCurrentDateTime();
$user_access_date = getCurrentDateTime();
try {
DB::beginTransaction();
$inputData['wave'] = 1;
$inputData['subscription_status'] = 1;
$inputData['last_payment_date'] = $last_payment_date;
$inputData['user_access_end_date'] = $user_access_date;
$inputData['credit_report_company_type'] = $inputData['source_type'];
if (!$data = (new Register())->createAccount($inputData)) {
throw new \Exception("Account creation failed.Please try again!");
}
if (isset($data['id']) && $data['id'] > 0) {
$creditReportData['user_id'] = $data['id'];
$creditReportData['email'] = $inputData['email'];
$creditReportData['password'] = $inputData['password'];
$creditReportData['report_type'] = $inputData['source_type'];
(new Creditreport())->insertCreditReport($creditReportData);
}
// Send Confirmation Email To Customer
$mailData['email'] = $inputData['email'];
$mailData['name'] = $inputData['first_name'] . ' ' . $inputData['last_name'];
$mailData['password'] = $inputData['password'];
(new Email())->clientConfirmationMail($mailData);
$this->message = "Account is created successfully.";
$this->code = config('constant.API_SUCCESS_CODE');
$this->type = 'success';
DB::commit();
} catch (\Exception $ex) {
DB::rollback();
$this->message = $ex->getMessage();
}
appLog($this->logDataCreate($logData, getModelDataMasking($inputData), $this->message, '', $this->code));
return back()->with([$this->type => $this->message]);
}
public function addProfile(AddProfileRequest $request)
{
$logData['action'] = "PROFILE_ADD";
$inputData = $request->all();
$data = [];
try {
DB::beginTransaction();
$user_id = getUserId();
if (!(new Register())->addProfile($inputData, $user_id)) {
throw new \Exception("Profile update failed.Please try again!");
}
DB::commit();
$message = "Profile updated successfully.";
$code = config('constant.API_SUCCESS_CODE');
$data = $inputData;
} catch (\Exception $ex) {
DB::rollback();
$message = $ex->getMessage();
$code = config('constant.API_FAILED_CODE');
}
appLog($this->logDataCreate($logData, $inputData, $message, $data, $code));
return $this->sendApiResponse(
$data,
$message,
$code
);
}
public function addPackage(AddPackageRequest $request)
{
$logData['action'] = "PACKAGE_ADD";
$inputData = $request->all();
$data = [];
try {
DB::beginTransaction();
$user_id = getUserId();
if (!(new Register())->addPackage($inputData, $user_id)) {
throw new \Exception("Package added failed.Please try again!");
}
DB::commit();
$message = "Package added successfully.";
$code = config('constant.API_SUCCESS_CODE');
$data = $inputData;
} catch (\Exception $ex) {
DB::rollback();
$message = $ex->getMessage();
$code = config('constant.API_FAILED_CODE');
}
appLog($this->logDataCreate($logData, $inputData, $message, $data, $code));
return $this->sendApiResponse(
$data,
$message,
$code
);
}
public function importCreditReportForUser(SetCreditReportRequest $request)
{
$logData['action'] = "IMPORT_CREDIT_REPORT";
$inputData = $request->all();
try {
$package_id = $inputData['package_id'];
$user_id = getUserId();
DB::beginTransaction();
$message = "Report not found";
$creditReport = new CreditReportService();
if (!(new Register())->addPackage($package_id, $user_id)) {
throw new \Exception("Package added failed.Please try again!");
}
$response = $creditReport->getSmartCreditHTML($inputData['email'], $inputData['password']);
if (!$response['status']) {
throw new \Exception($message);
}
$creditReportObj = app(\App\Models\Creditreport::class);
$credit_reportData['user_id'] = $user_id;
$credit_reportData['html_content'] = $response['html'];
if (!$creditReportObj->addOrUpdateCreditReport($credit_reportData)) {
throw new \Exception("Report upload problem.");
}
$message = "Your report has been saved successfully";
$code = config('constant.API_SUCCESS_CODE');
DB::commit();
} catch (\Exception $ex) {
DB::rollback();
$message = $ex->getMessage();
$code = config('constant.API_FAILED_CODE');
}
appLog($this->logDataCreate($logData, $inputData, $message, $inputData, $code));
return $this->sendApiResponse(
[],
$message,
$code
);
}
public function getUserInfoById()
{
$logData['action'] = "GET_USER_INFO_BY_ID";
$userObj = app(User::class);
$user_id = getUserId();
$userData = $userObj->getUserByUserId($user_id);
$security_questions = (new SecurityQuestion())->getSecurityQuestion();
$userData->password = customDecrypt($userData->password);
$message = "User not found";
$code = config('constant.API_FAILED_CODE');
$userData['questionList'] = $security_questions;
if (!empty($userData)) {
$message = "User info fetched successfully";
$code = config('constant.API_SUCCESS_CODE');
}
appLog($this->logDataCreate($logData, $user_id, $message, $userData, $code));
return $this->sendApiResponse(
$userData,
$message,
$code
);
}
public function makePaymentByUser(MakePaymentRequest $request): JsonResponse
{
$logData['action'] = "MAKE_PAYMENT_START";
$message = "Unknown error occurred.";
$status_code = config('constant.API_FAILED_CODE');
$inputData = $request->all();
$userData = (new Register())->emailVarification($inputData['email']);
if (!empty($userData)) {
try {
$user_id = $userData['id'];
$inputData['user_id'] = $user_id;
$inputData['amount'] = config('constant.PLAN_AMOUNT');
$package = (new Package());
$package->makePayment($inputData);
if ($package->status_code == config('constant.API_SUCCESS_CODE')) {
$inputData['email'] = $userData['email'];
$inputData['name'] = $userData['first_name'] . ' ' . $userData['last_name'];
$this->paymentMail($inputData);
}
$message = "Successfully Saved.";
$status_code = config('constant.API_SUCCESS_CODE');
Auth::loginUsingId($user_id);
} catch (\Exception $ex) {
$logData['exception']['message'] = $ex->getMessage();
$logData['exception']['trace'] = $ex->getTraceAsString();
}
$this->data = $userData;
$this->message = $message;
$this->status_code = $status_code;
}
appLog($this->logDataCreate($logData, getModelDataMasking($inputData), $this->message, getModelDataMasking($this->data), $this->status_code));
return $this->sendApiResponse(
$this->data,
$this->message,
$this->status_code
);
}
public function makePayment(Request $request): JsonResponse
{
$postData = $request->all();
$logData['action'] = "MAKE_PAYMENT_START";
$data = [];
$message = '';
$status_code = config('constant.API_FAILED_CODE');
$userData = (new User())->getUserByEmail($postData['email']);
if (!empty($userData)) {
$user_question_answer = (new UserSecurityQuestionAnswer())->getUserSecurityQuestionAnswer($userData['id']);
$inputData = [];
$inputData['id'] = $userData['id'];
$inputData["first_name"] = $userData["first_name"];
$inputData["last_name"] = $userData["last_name"];
$inputData['answer'] = $user_question_answer['answer'] ?? "";
$inputData['question_id'] = $user_question_answer['question_id'] ?? 1;
$inputData["email"] = $userData["email"];
$inputData["password"] = customDecrypt($userData["password"]);
$inputData["street_no"] = $userData["street_no"];
$inputData["street_name"] = $userData["street_name"];
$inputData["city"] = $userData["city"];
$inputData["state"] = $userData["state"];
$inputData["birth_date"] = $userData["birth_date"];
$inputData["ssn"] = $userData["ssn"];
$inputData['card_number'] = $postData['card_number'];
$inputData['expiry'] = $postData['expiry'];
$inputData["amount"] = $postData["amount"];
$inputData['package_id'] = "2";
$inputData["full_ssn"] = $postData["full_ssn"];
$inputData["phone"] = $postData["phone"];
$inputData["zip_code"] = $postData["zip_code"];
$package = (new Package());
$package->purchasePackage($inputData);
if ($package->status_code == config('constant.API_SUCCESS_CODE')) {
Auth::loginUsingId($userData['id']);
}
$data = $package->data;
$message = $package->message;
$status_code = config('constant.API_SUCCESS_CODE');
appLog($this->logDataCreate($logData, $postData, $message, $data, $status_code));
}
return $this->sendApiResponse(
$data,
$message,
$status_code
);
}
public function emailVerification(CreateAccountRequest $request)
{
$logData['action'] = "EMAIL_VERIFICATION";
$inputData = $request->all();
$this->data = [];
$this->message = '';
$this->status_code = config('constant.API_SUCCESS_CODE');
$result = [];
if(config('app.REPORT_PROVIDER') == '3') {
$result = (new Package())->checkIsEmailExistOnSmartCredit($inputData);
}
// elseif (config('app.REPORT_PROVIDER') == '2'){
// $result = $this->identityIQemailVerification();
// }
if (isset($result['status']) && $result['status']) {
$this->status_code = config('constant.API_FAILED_CODE');
$this->message = $result['message'];
}
return $this->sendApiResponse(
$this->data,
$this->message,
$this->status_code
);
}
private function identityIQemailVerification()
{
$result['status'] = true;
$result['message'] = "You already have an account with identityIQ";
return $result;
}
public function profileVerification(CustomerProfileRequest $request)
{
$logData['action'] = "SSN_VERIFICATION";
$inputData = $request->all();
$this->data = [];
$this->message = '';
$this->status_code = config('constant.API_SUCCESS_CODE');
$smartCreditRequestData['ssn'] = $inputData['full_ssn'];
$smartCreditRequestData['email'] = $inputData['email'];
$result =[];
if(config('app.REPORT_PROVIDER') == '3') {
$result = (new SmartCredit(config('app.CLIENT_KEY')))
->setData($smartCreditRequestData)
->checkIsSsnExistOnSmartCredit();
}
elseif (config('app.REPORT_PROVIDER') == '1'){
$result = $this->identityIQemailVerification();
}
if (isset($result['status']) && $result['status']) {
$this->status_code = config('constant.API_FAILED_CODE');
$this->message = $result['message'];
}
return $this->sendApiResponse(
$this->data,
$this->message,
$this->status_code
);
}
public function getSecurityQuestion(Request $request): JsonResponse
{
$logData['action'] = "GET_SECURITY_QUESTION";
$questions = (new package())->securityQuestions();
return $this->sendApiResponse(
$questions->data,
$questions->message,
$questions->status_code
);
}
public function createCustomer(CustomerProfileRequest $request): JsonResponse
{
$logData['action'] = "CREATE_CUSTOMER_START";
appLog($logData);
$inputData = $request->all();
$inputData['status'] = 2; // status = 2 for inactive user, 1 for active
// Insert User table
$inputData['credit_report_company_type'] = config('app.REPORT_PROVIDER');
$userData = $this->addUser($inputData);
$inputData['user_id'] = $userData['id'];
$inputData['status_code'] = config('constant.API_SUCCESS_CODE');
// insert credit report table and user update
(new Package())->purchasePackage($inputData);
$this->status_code = config('constant.API_SUCCESS_CODE');
$this->message = '';
// Send Email To Admin,Employee and Customer
$mailData['email'] = $inputData['email'];
$mailData['name'] = $inputData['first_name'] . ' ' . $inputData['last_name'];
(new Email())->clientRegistrationMail($mailData);
$logData['action'] = "CREATE_CUSTOMER_END";
appLog($logData);
return $this->sendApiResponse(
$this->data,
$this->message,
$this->status_code
);
}
public function getIdentityQuestionAnswer(Request $request): JsonResponse
{
$logData['action'] = "GET_IDENTITY_QUESTION_ANSWER";
$questions = (new package())->identityQuestionAnswer();
return $this->sendApiResponse(
$questions['data']['idVerificationCriteria'],
$questions['message'],
$questions['status_code']
);
}
public function postIdentityQuestion(Request $request): JsonResponse
{
$inputData = $request->all();
$questions = (new package())->submitIdentityQuestionAnswer($inputData);
if ($questions->status_code == config('constant.API_SUCCESS_CODE')) {
$questions->data = $this->insertSecurityQuestionAnswer($inputData);
}
return $this->sendApiResponse(
$questions->data,
$questions->message,
$questions->status_code
);
}
private function insertSecurityQuestionAnswer($inputData)
{
$userQuestion = [];
$logData['action'] = "INSERT_USER_IDENTITY_QUESTION_ANSWER";
$userData = (new Register())->emailVarification($inputData['email']);
if (!empty($userData)) {
$userQuestion = ['user_id' => $userData['id'], 'data' => $inputData['security_question_answer']];
(new UserIdentityQuestionAnswer())->insertData($userQuestion);
$this->status_code = config('constant.API_SUCCESS_CODE');
$this->message = 'successfully inserted user identity question answer';
}
appLog($this->logDataCreate($logData, $userQuestion, $this->message, $this->data, $this->status_code));
return $userData;
}
public function insertEmployee(EmployeeRegistrationRequest $request)
{
$inputData = $request->all();
$inputData['user_type'] = 2;
$userData = $this->addUser($inputData);
if (!empty($userData)) {
$inputData['employee_id'] = $userData['id'];
(new Permission())->insertUserPermission($inputData);
}
return back()->with([$this->type => $this->message]);
}
public function userValidationInCreditReportProvider(Request $request)
{
$code = config('constant.API_FAILED_CODE');
$message = 'Email and Password is not valid in Identity IQ.';
$inputData = $request->all();
// $isValid = (new CreditReportService())->validateUserInCreditReportProvider($inputData);
$isValid = true; // client told no need to check IQ
if($isValid) {
$message = 'Email and Password is valid.';
$code = config('constant.API_SUCCESS_CODE');
}
return $this->sendApiResponse(
$isValid,
$message,
$code
);
}
private function addUser($inputData)
{
$logData['action'] = "CREATE_ACCOUNT";
$this->data = [];
try {
DB::beginTransaction();
if (!$this->data = (new Register())->createAccount($inputData)) {
throw new \Exception("Account creation failed.Please try again!");
}
$this->message = "Account created successfully.";
$this->type = 'success';
$this->status_code = config('constant.API_SUCCESS_CODE');
DB::commit();
} catch (\Exception $ex) {
DB::rollback();
$this->message = $ex->getMessage();
$this->status_code = config('constant.API_FAILED_CODE');
}
appLog($this->logDataCreate($logData, getModelDataMasking($inputData), $this->message, getModelDataMasking($this->data), $this->status_code));
return $this->data;
}
private function logDataCreate($logData, $request, $message, $response, $code)
{
$logData['data']['request'] = $request;
$logData['data']['message'] = $message;
$logData['data']['response'] = $response;
$logData['data']['code'] = $code;
return $logData;
}
}

View File

@@ -0,0 +1,44 @@
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use App\Models\Recurring;
use Illuminate\Http\Request;
use App\Services\ReportService;
class ReportController extends Controller
{
//
public function salesReport(Request $request)
{
$inputData=$this->getInputData($request->only(['clientName','fdate','tdate','pageLimit']));
$salesData=$this->getSalesReportData($inputData);
return view('report.sales_report',compact('salesData','inputData'));
}
public function recurringReport(Request $request)
{
$inputData=$this->getInputData($request->only(['clientName','fdate','tdate']));
$recurringInfo=$this->getRecurringReportData($inputData);
return view('report.recurring_list',compact('recurringInfo','inputData'));
}
private function getRecurringReportData($inputData)
{
$recurringInfo=(new Recurring())->getTransactions($inputData);
return $recurringInfo;
}
private function getSalesReportData($inputData)
{
$salesData= (new ReportService())->getSalesReport($inputData);
return $salesData;
}
private function getInputData($formData)
{
$items = empty($formData['pageLimit']) ? config('constant.PAGINATION_LIMIT'):$formData['pageLimit'];
$fdate= (!empty($formData['fdate']))?getStringToDate($formData['fdate']):'';
$tdate=(!empty($formData['tdate']))?getStringToDate($formData['tdate']):'';
$clientName=(!empty($formData['clientName']))?$formData['clientName']:'';
$inputData=['clientName'=>$clientName,'fdate'=>$fdate,'tdate'=>$tdate,'pageLimit'=>$items];
return $inputData;
}
}

View File

@@ -0,0 +1,75 @@
<?php
namespace App\Http\Controllers;
use App\Models\SecurityQuestion;
use App\Utility\ActionLogCreate;
use App\Http\Requests\SecurityQuestionRequest;
use App\Traits\ApiResponseTrait;
use Symfony\Component\HttpFoundation\Response;
class SecurityQuestionController extends Controller
{
use ApiResponseTrait;
private $message;
private $code;
private $data;
private $action;
private $type;
public function __construct()
{
$this->action='';
$this->type='error';
$this->message = 'Fail';
$this->code = config('constant.API_FAILED_CODE');
$this->data=[];
}
public function index()
{
$security_questions = (new SecurityQuestion())->getSecurityQuestion();
return view('security_question.security_question',compact('security_questions'));
}
public function createSecurityQuestion(SecurityQuestionRequest $request)
{
$this->action='INSERT_SECURITY_QUESTION';
$this->message='can not save data.';
$inputData=['questions'=>$request['question']];
$returnData = (new SecurityQuestion())->insertSecurityQuestion($inputData);
if (!empty($returnData)) {
$this->message='Successfully Saved';
$this->code=config('constant.API_SUCCESS_CODE');
$this->type='success';
}
ActionLogCreate::logDataCreate( $this->action,$request->all(),$this->message,$returnData,$this->code);
return back()->with($this->type, $this->message);
}
public function getSecurityQuestion(){
$result=[];
$this->action='INSERT_SECURITY_QUESTION';
$this->message='can not get data.';
$security_questions = (new SecurityQuestion())->getSecurityQuestion();
if(!empty($security_questions)){
$this->message = "Security Question info fetched successfully";
$this->code = config('constant.API_SUCCESS_CODE');
foreach ($security_questions as $security_question)
{
$result['id']=$security_question['id'];
$result['value']=$security_question['questions'];
}
}
ActionLogCreate::logDataCreate( $this->action,'',$this->message,$security_questions,$this->code);
return response()->json([
'status_code'=> $this->code,
'message' => $this->message,
'security_question' => $result,
],Response::HTTP_OK);
// return $this->sendApiResponse(
// $result,
// $this->message,
// $this->code
// );
}
}

View File

@@ -0,0 +1,102 @@
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use App\Models\Support;
use App\Models\Support_Reply;
use Illuminate\Http\Request;
use App\Http\Requests\AddSupportRequest;
class SupportController extends Controller
{
private $message;
private $code;
private $data;
private $type;
public function __construct()
{
$this->message = 'Can not save';
$this->code = config('constant.API_FAILED_CODE');
$this->data = [];
$this->type = "error";
}
public function index(Request $request){
$inputData = $request->all();
$items = empty($request->pageLimit) ? config('constant.PAGINATION_LIMIT'):$request->pageLimit;
$searchData=[
'status'=> $request['status']??0,
'search_value'=>$request['search_value'],
'pageLimit' => $items,
'user_type'=> auth()->user()->user_type,
'user_id' => auth()->user()->id
];
$supports = (new Support())->list($searchData);
return view('support.list', compact('supports','searchData'));
}
public function insertClientSupport(AddSupportRequest $request)
{
$action='ADD_SUPPORT_BY_CLIENT';
$inputData = $request->all();
$inputData['sender_id'] = auth()->user()->id;
$inputData['message'] = $inputData['support_text'];
$inputData['title'] = $inputData['support_title'];
$inputData['status'] = 0;
$return_data = (new Support())->addSupport($inputData);
if($return_data)
{
$this->type = "success";
$this->message = 'Saved successfully';
}
return back()->with([$this->type => $this->message]);
}
public function add(AddSupportRequest $request)
{
$file_name = null;
$inputData = $request->all();
$inputData['sender_id'] = auth()->user()->id;
$inputData['message'] = $inputData['support_text'];
$inputData['title'] = $inputData['support_title'];
$inputData['support_id'] = $inputData['id'];
if (!empty($request->file('doc_file'))) {
$file = $request->file('doc_file');
$file_data = imageFileRotate($request->file('doc_file'));
$file_name = time() . "_" . removeAnySpaces($file->getClientOriginalName(), '_');
$file_path = 'support_ticket' . DIRECTORY_SEPARATOR . $inputData['id'];
uploadFile($file_path, $file_name, $file_data);
}
$inputData['attachment_path'] = $file_name;
$return_data = (new Support_Reply())->addSupportReply($inputData);
if ($return_data) {
$this->type = "success";
$this->message = 'Saved successfully';
}
return back()->with([$this->type => $this->message]);
}
public function view($id){
$inputData['sender_id'] = auth()->user()->id;
$inputData['support_id'] = $id;
(new Support_Reply())->updateSupportReply($inputData);
$supports = (new Support())->getSupportById($inputData);
$support_data = (new Support())->getNotifcation($inputData['sender_id'],auth()->user()->user_type);
setSession('new_ticket',$support_data);
return view('support.view', compact('supports'));
}
}

View File

@@ -0,0 +1,99 @@
<?php
namespace App\Http\Controllers;
use App\Http\Requests\LinkRequest;
use App\Models\VideoSetting;
use App\Utility\ActionLogCreate;
use Illuminate\Http\Request;
class TrainingVideoController extends Controller
{
private $message;
private $code;
private $data;
private $action;
private $type;
public function __construct()
{
$this->action='';
$this->type='error';
$this->message = 'Fail';
$this->code = config('constant.API_FAILED_CODE');
$this->data=[];
}
public function index(Request $request)
{
$inputData['is_welcome_video'] = false;
$videos=(new VideoSetting())->getVideos($inputData);
return view('training_video.list',compact('videos'));
}
public function list(Request $request)
{
$videos = (new VideoSetting())->getVideos();
return view('training_video.video_list',compact('videos'));
}
public function createTrainingVideo(LinkRequest $request)
{
$this->action='INSERT_TRAINING_VIDEO';
$this->message='can not save data.';
$inputData = $request->only(['section_name','link','status','welcome_video_create']);
$inputData['is_welcome_video'] = isset($inputData['welcome_video_create']);
$returnData = (new VideoSetting())->insertVideo($inputData);
if (!empty($returnData)) {
$this->message='Successfully Saved';
$this->code=config('constant.API_SUCCESS_CODE');
$this->type='success';
}
ActionLogCreate::logDataCreate( $this->action,$request->all(),$this->message,$returnData,$this->code);
return back()->with($this->type, $this->message);
}
public function editTrainingVideo(Request $request)
{
$this->action='EDIT_TRAINING_VIDEO';
$this->message='can not update data.';
$validated = $request->validate([
'edit_section_id' => 'required|gt:0',
'edit_link' => 'required|regex:'.config('constant.VIMEO_VIDEO_LINK_VALIDATION'),
'edit_status' => 'required|numeric',
]);
$inputData = ['section_id'=>$request["edit_section_id"],'link'=>$request["edit_link"],'status'=>$request["edit_status"]];
$inputData['is_welcome_video'] = isset($request['welcome_video_edit']);
$returnData = (new VideoSetting())->updateVideo($inputData);
if (!empty($returnData)) {
$this->message='Update Successfully';
$this->code=config('constant.API_SUCCESS_CODE');
$this->type='success';
}
ActionLogCreate::logDataCreate( $this->action,$request->all(),$this->message,$returnData,$this->code);
return back()->with($this->type, $this->message);
}
public function deleteTrainingVideo(Request $request)
{
$this->action='DELETE_TRAINING_VIDEO';
$this->message='can not delete data.';
$validated = $request->validate([
'delete_section_id' => 'required|gt:0',
]);
$inputData=['section_id'=>$request['delete_section_id']];
if($inputData['section_id']>0) {
$returnData = (new VideoSetting())->deleteVideos($inputData);
if (!empty($returnData)) {
$this->message='Successfully Deleted';
$this->code=config('constant.API_SUCCESS_CODE');
$this->type='success';
}
ActionLogCreate::logDataCreate($this->action,$request->all(),$this->message,$returnData,$this->code);
}
return back()->with($this->type, $this->message);
}
}

View File

@@ -0,0 +1,340 @@
<?php
namespace App\Http\Controllers;
use App\Http\Requests\ManageClientRequest;
use App\Http\Requests\UserEditRequest;
use App\Http\Requests\PasswordChangeRequest;
use App\Http\Requests\EditEmployeeInfoRequest;
use App\Models\Creditreport;
use App\Models\Module;
use App\Models\Permission;
use App\Models\Sale;
use App\Models\User;
use App\Models\UserIdentityQuestionAnswer;
use App\Services\ClientService;
use App\Services\UploadMedia;
use App\Utility\ActionLogCreate;
use App\Utility\Email;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use mysql_xdevapi\Exception;
class UserController extends Controller
{
private $message;
private $code;
private $data;
private $type;
public function __construct()
{
$this->message = 'Fail';
$this->code = config('constant.API_FAILED_CODE');
$this->data = [];
$this->type = "error";
}
public function showManageClient(){
$auth_user = auth()->user();
$auth_user_id = $auth_user->id;
$uploadMediaObj = app(\App\Models\Uploadmedia::class);
$upload_medias = $uploadMediaObj->getUploadMediaByUserId($auth_user_id);
$question_answer = (new UserIdentityQuestionAnswer())->getUserIdentityQuestionAnswer($auth_user_id);
$this->setCardNumber();
$is_first_login = false;
if($auth_user->is_first_login == 1){
setSession('is_first_login',1);
$is_first_login = true;
}
return view('auth.manage_client',compact('upload_medias','is_first_login','question_answer'));
}
public function manageClient(ManageClientRequest $request){
$action='CLIENT_INFORMATION_UPDATE';
$auth_user_id = auth()->id();
$userObj = app(\App\Models\User::class);
$inputData['creditreport'] = array_filter($request->creditreport);
$inputData['html_content'] = $request->html_content;
try {
if ($userObj->userupdate($inputData['creditreport'], $auth_user_id)) {
$creditReportData['user_id'] = $auth_user_id;
$creditReportData['password'] = customEncrypt($inputData['creditreport']['password']);
$creditReportData['report_type'] = $inputData['creditreport']['credit_report_company_type'];
(new Creditreport())->updateCreditReportByUserId($creditReportData);
// (new UploadMedia($request))->uploadmedia();
$this->data = ['client_id'=> $auth_user_id];
$this->code = config('constant.API_SUCCESS_CODE');
$this->message = "Information is updated successfully.";
$this->type = "success";
if(getSession('is_first_login') == 1) {
Auth::user()->update(['is_first_login' => 0,'is_import'=> 1]);
return redirect(route('get.letter'));
}
}
}catch (\Exception $ex){
$this->code = config('constant.API_FAILED_CODE');
$this->message = "File upload failed.";
$this->data = $ex->getMessage();
$this->type = "error";
}
ActionLogCreate::logDataCreate($action,getModelDataMasking($inputData['creditreport']),$this->message,$this->data,$this->code);
return back()->with([$this->type => $this->message]);
}
public function uploadCreditReport(Request $request){
$action='UPLOAD_CREDIT_REPORT';
$this->message = 'Report is not uploaded. Please try again!';
$this->type = 'error';
try {
DB::beginTransaction();
$auth_user_id = auth()->id();
$creditReportObj = app(\App\Models\Creditreport::class);
$inputData = $request->all();
$credit_reportData['user_id'] = $auth_user_id;
$credit_reportData['html_content'] = $inputData['html_content'];
if (!$creditReportObj->addOrUpdateCreditReport($credit_reportData)) {
throw new \Exception("Report upload problem.");
}
Auth::user()->update([
'is_first_login' => 0
]);
DB::commit();
$this->data = $creditReportObj;
$this->message = 'Report uploaded successfully';
$this->code = config('constant.API_SUCCESS_CODE');
$this->type = 'success';
}catch (\Exception $ex){
$this->data= $ex->getMessage();
}
ActionLogCreate::logDataCreate($action,getModelDataMasking($request->all()),$this->message,getModelDataMasking($this->data),$this->code);
return back()->with([$this->type => $this->message]);
}
public function getAllClient(Request $request)
{
$items = empty($request->pageLimit) ? config('constant.PAGINATION_LIMIT'):$request->pageLimit;
$searchData=[
'account_status'=>$request['account_status'],
'search_value'=>$request['search_value'],
'payment_status'=>$request['payment_status'] ?? "",
'pageLimit'=>$items
];
$users =(new ClientService())->getUsers($searchData) ;
return view('client.list',compact('users','searchData'));
}
public function getClientInfo($id)
{
$user = (new ClientService())->getUserInfoById($id);
if (!empty($user['data'])) {
$question_answer= (new UserIdentityQuestionAnswer())->getUserIdentityQuestionAnswer($id);
$this->message='Fetched client info successfully';
$this->code=config('constant.API_SUCCESS_CODE');
return view('client.view', compact('user','question_answer'));
}
return redirect()->route('get.clients')->with('error','No user data found.');
}
public function updateClientInfo(UserEditRequest $request)
{
$action='EDIT_USER_INFO';
$this->message='Do not update user data.';
$inputData = $request->all();
$inputData['credit_report_company_type'] = $inputData['source_type'];
if(!empty($inputData['user_access_date'])) {
$inputData['user_access_date'] = getStringToDateTime($inputData['user_access_date']);
$inputData['last_payment_date'] = getCurrentDateTime();
$inputData['subscription_status'] = 1;
}
if(!empty($inputData['last_import_date'])) {
$inputData['last_import_date'] = getStringToDateTime($inputData['last_import_date']);
}
$user = (new ClientService())->updateUserInfoById($inputData);
if(!empty($user)){
$creditReportData['user_id'] = $inputData['id'];
$creditReportData['email'] = $inputData['email'];
$creditReportData['password'] = customEncrypt($inputData['password']);
$creditReportData['report_type'] = $inputData['source_type'];
(new Creditreport())->updateCreditReportByUserId($creditReportData);
$this->message='Successfully update user data.';
$this->code = config('constant.API_SUCCESS_CODE');
$this->type ='success';
}
$requestData = getModelDataMasking($request->all());
ActionLogCreate::logDataCreate($action,$requestData,$this->message,'',$this->code);
return back()->with($this->type,$this->message);
}
public function updateClientInfoById(Request $request)
{
$inputData = $request->all();
$mailData = [];
$saveData = [];
$action = 'CLIENT_ACTIVATION';
if($inputData['type'] == 2)
{
$action = 'RESET_IMPORT_BUTTON';
$saveData['is_import'] = 1;
}
if($inputData['type'] == 1){
$action = 'CLIENT_ACTIVATION';
$saveData['subscription_status'] = 1;
$saveData['status'] = 1;
}
$user = (new User())->getUserByUserId($inputData['client_id']);
if (!empty($user)) {
(new User())->userupdate($saveData,$inputData['client_id']);
$mailData['email'] = $user['email'];
$mailData['name'] = $user['first_name'] . ' ' . $user['last_name'];
$mailData['password'] = customDecrypt($user['password']);
$this->message='Import Credit Report button has been reset successfully.';
if($inputData['type'] == 1) {
$this->message='Client is activated successfully.';
(new Email())->clientConfirmationMail($mailData);
}
$this->code=config('constant.API_SUCCESS_CODE');
$user['data'] = $user;
$this->type = 'success';
}
ActionLogCreate::logDataCreate( $action,getModelDataMasking($mailData),$this->message,$this->type,$this->code);
return redirect()->route('get.client.info',$inputData['client_id'])->with( $this->type,$this->message);
}
public function deleteClient($id)
{
$action='DELETE_CLIENT';
$type='error';
if($id>0) {
$returnData= (new User())->deleteUser($id);
if($returnData) {
$this->message = 'Client has deleted successfully';
$this->code = config('constant.API_SUCCESS_CODE');
$type = 'success';
}
ActionLogCreate::logDataCreate($action,$id,$this->message,$id,$this->code);
}
return back()->with([$type=>$this->message]);
}
public function changeAdminInfo(PasswordChangeRequest $request)
{
$action='PASSWORD_CHANGE';
$inputData=$request->all();
$password = customEncrypt($inputData['current_password']);
Auth::user()->update([
'email' => $inputData['email'],
'password' => $password
]);
return back()->with(['success'=>'Admin information has been changed Successfully.']);
}
public function getEmployeeInfo($id)
{
$employee = (new User())->getUserByUserId($id);
$employee_permission = (new Permission())->getPermittedSubmoduleIdListByUserId($id);
$moduleSubmoduleAssoc = (new Module())->getModuleSubmoduleAssoc();
return view('employee.employee_info_edit',compact('employee','employee_permission','moduleSubmoduleAssoc'));
}
public function updateEmployeeInfo(EditEmployeeInfoRequest $request)
{
$action = 'EMPLOYEE_UPDATE';
$this->message = 'Employee permission can not be updated.';
$inputData = $request->all();
$result = (new User())->updateEmployeeInfo($inputData);
if($result) {
$this->message = 'Employee permission have updated successfully.';
$this->code = config('constant.API_SUCCESS_CODE');
$this->data = ['true'];
$this->type = "success";
}
$requestData = getModelDataMasking($request->all());
ActionLogCreate::logDataCreate($action,$requestData,$this->message,$result,$this->code);
return back()->with([$this->type=>$this->message]);
}
public function employeeList(Request $request)
{
$items = empty($request->pageLimit) ? config('constant.PAGINATION_LIMIT'):$request->pageLimit;
$searchData=[
'search_value'=>$request['search_value'],
'pageLimit'=>$items
];
$employees = (new User())->getEmployees($searchData) ;
return view('employee.employee_list',compact('employees','searchData'));
}
public function createEmployee(Request $request)
{
$moduleSubmoduleAssoc = (new Module())->getModuleSubmoduleAssoc();
return view('employee.employee_info',compact('moduleSubmoduleAssoc'));
}
public function uploadClientImage(Request $request){
$input_data = $request->only(['doc_type','uploadmedia']);
$action = "UPLOAD_CLIENT_DOC";
try {
(new UploadMedia($request))->uploadmedia();
$this->code = config('constant.API_SUCCESS_CODE');
$this->message = "File is uploaded successfully.";
$this->type = "success";
if($input_data['doc_type'] == 9) {
getUserImagesAndDoc(auth()->user()->id);
}
}catch (\Exception $ex){
$this->code = config('constant.API_FAILED_CODE');
$this->message = "File upload failed.";
$this->data = $ex->getMessage();
$this->type = "error";
}
ActionLogCreate::logDataCreate($action,$input_data,$this->message,$this->data,$this->code);
return back()->with([$this->type => $this->message]);
}
private function setCardNumber(){
$key = 'card_no';
unsetCache($key);
if(empty(getCache($key))){
$user_last_payment = (new Sale())->getLatestSalesByUserId(auth()->id());
if(!empty($user_last_payment)) {
setCache($key, $user_last_payment['cc_number']);
}
}
}
}

72
app/Http/Kernel.php Normal file
View File

@@ -0,0 +1,72 @@
<?php
namespace App\Http;
use Illuminate\Foundation\Http\Kernel as HttpKernel;
class Kernel extends HttpKernel
{
/**
* The application's global HTTP middleware stack.
*
* These middleware are run during every request to your application.
*
* @var array
*/
protected $middleware = [
// \App\Http\Middleware\TrustHosts::class,
\Fruitcake\Cors\HandleCors::class,
\App\Http\Middleware\TrustProxies::class,
\App\Http\Middleware\PreventRequestsDuringMaintenance::class,
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
\App\Http\Middleware\TrimStrings::class,
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
];
/**
* The application's route middleware groups.
*
* @var array
*/
protected $middlewareGroups = [
'web' => [
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
// \Illuminate\Session\Middleware\AuthenticateSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],
'api' => [
'throttle:api',
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],
];
/**
* The application's route middleware.
*
* These middleware may be assigned to groups or used individually.
*
* @var array
*/
protected $routeMiddleware = [
'auth' => \App\Http\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
'can' => \Illuminate\Auth\Middleware\Authorize::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
'requestValidate'=>\App\Http\Middleware\RequestValidate::class,
'permission'=> \App\Http\Middleware\Permission::class,
'permissionroute'=> \App\Http\Middleware\RoutePermission::class,
'checkSubscription'=> \App\Http\Middleware\CheckSubcription::class
];
}

View File

@@ -0,0 +1,21 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Auth\Middleware\Authenticate as Middleware;
class Authenticate extends Middleware
{
/**
* Get the path the user should be redirected to when they are not authenticated.
*
* @param \Illuminate\Http\Request $request
* @return string|null
*/
protected function redirectTo($request)
{
if (! $request->expectsJson()) {
return route('login');
}
}
}

View File

@@ -0,0 +1,26 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
class CheckSubcription
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
*/
public function handle(Request $request, Closure $next)
{
if(!isClientSubscription()){
return back()->withErrors(['message'=>'You do not have permission on the page']);
}
return $next($request);
}
}

View File

@@ -0,0 +1,17 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
class EncryptCookies extends Middleware
{
/**
* The names of the cookies that should not be encrypted.
*
* @var array
*/
protected $except = [
//
];
}

View File

@@ -0,0 +1,30 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
class Permission
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
*/
public function handle(Request $request, Closure $next,$param = "")
{
$condition = (isClient() && $param == "client") || (isAdmin() && $param == "admin") || isEmployee();
if($condition){
if(isEmployee() && !isPermitted()){
return redirect(route('get.clients'))->withErrors(["message"=>"You don't have permission on the page."]);
}
return $next($request);
}
return back()->withErrors(["message"=>"You don't have permission on the page."]);
}
}

View File

@@ -0,0 +1,17 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance as Middleware;
class PreventRequestsDuringMaintenance extends Middleware
{
/**
* The URIs that should be reachable while maintenance mode is enabled.
*
* @var array
*/
protected $except = [
//
];
}

View File

@@ -0,0 +1,31 @@
<?php
namespace App\Http\Middleware;
use App\Providers\RouteServiceProvider;
use Closure;
use Illuminate\Support\Facades\Auth;
class RedirectIfAuthenticated
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string[]|null ...$guards
* @return mixed
*/
public function handle($request, Closure $next, ...$guards)
{
$guards = empty($guards) ? [null] : $guards;
foreach ($guards as $guard) {
if (Auth::guard($guard)->check()) {
return redirect(RouteServiceProvider::HOME);
}
}
return $next($request);
}
}

View File

@@ -0,0 +1,42 @@
<?php
namespace App\Http\Middleware;
use App\Traits\ApiResponseTrait;
use Closure;
use Illuminate\Http\Request;
class RequestValidate
{
use ApiResponseTrait;
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
*/
public function handle(Request $request, Closure $next)
{
if(!empty($request->header('security-key'))) {
/*$json = customDecrypt($request->header('security-key'));
$json_decoded = json_decode($json,true);
if(isset($json_decoded['user_id']) && $json_decoded['user_id'] > 0){
// $request->headers['user_id'] = $json_decoded['user_id'];
setUserId($json_decoded['user_id']);
return $next($request);
}*/
//dd($request->header('security-key'));
setSecurityKey($request->header('security-key'));
return $next($request);
}
return $this->sendApiResponse(
[],
"Unauthorized request",
400,
419
);
}
}

View File

@@ -0,0 +1,23 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
class RoutePermission
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
*/
public function handle(Request $request, Closure $next)
{
return $next($request);
}
}

View File

@@ -0,0 +1,18 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware;
class TrimStrings extends Middleware
{
/**
* The names of the attributes that should not be trimmed.
*
* @var array
*/
protected $except = [
'password',
'password_confirmation',
];
}

View File

@@ -0,0 +1,20 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Http\Middleware\TrustHosts as Middleware;
class TrustHosts extends Middleware
{
/**
* Get the host patterns that should be trusted.
*
* @return array
*/
public function hosts()
{
return [
$this->allSubdomainsOfApplicationUrl(),
];
}
}

View File

@@ -0,0 +1,23 @@
<?php
namespace App\Http\Middleware;
use Fideloper\Proxy\TrustProxies as Middleware;
use Illuminate\Http\Request;
class TrustProxies extends Middleware
{
/**
* The trusted proxies for this application.
*
* @var array|string|null
*/
protected $proxies;
/**
* The headers that should be used to detect proxies.
*
* @var int
*/
protected $headers = Request::HEADER_X_FORWARDED_ALL;
}

View File

@@ -0,0 +1,17 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
class VerifyCsrfToken extends Middleware
{
/**
* The URIs that should be excluded from CSRF verification.
*
* @var array
*/
protected $except = [
//
];
}

View File

@@ -0,0 +1,20 @@
<?php
namespace App\Http\Requests;
class AddPackageRequest extends ApiBaseRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'package_id'=>"required|integer",
];
}
}

View File

@@ -0,0 +1,26 @@
<?php
namespace App\Http\Requests;
class AddProfileRequest extends ApiBaseRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'street_no'=>'required|regex:'.$this->script_validation_rule,
'street_name'=>'required|regex:'.$this->script_validation_rule,
'city'=>'required|regex:'.$this->script_validation_rule,
'state'=>'required|regex:'.$this->script_validation_rule,
'zip_code'=>'required|regex:'.$this->script_validation_rule,
'ssn'=>'required|integer',
'phone'=>'required|regex:'.$this->script_validation_rule,
];
}
}

View File

@@ -0,0 +1,21 @@
<?php
namespace App\Http\Requests;
class AddSupportRequest extends BaseRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'support_text'=>'required',
'support_title'=>'required'
];
}
}

View File

@@ -0,0 +1,48 @@
<?php
namespace App\Http\Requests;
use App\Traits\ApiResponseTrait;
use Illuminate\Contracts\Validation\Validator;
use Illuminate\Http\Exceptions\HttpResponseException;
use Illuminate\Validation\ValidationException;
class ApiBaseRequest extends BaseRequest
{
use ApiResponseTrait;
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
];
}
protected function passedValidation()
{
$request = $this->all();
$rules = array_keys($this->rules());
$final_data = [];
if (!empty($rules)) {
foreach ($rules as $rule) {
if (isset($request[$rule])) {
$final_data[$rule] = $request[$rule];
}
}
}
$this->replace($final_data);
}
protected function failedValidation(Validator $validator)
{
$errors = (new ValidationException($validator))->errors();
throw new HttpResponseException($this->sendApiResponse($errors,"validation error",config('constant.API_VALIDATION_FAILED')));
}
}

View File

@@ -0,0 +1,38 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class BaseRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
protected string $script_validation_rule = '/^[^<>]+$/';
protected string $RULE_EXPIRY_REGEX = "/^(0[1-9]|1[0-2]|[1-9])\/(1[4-9]|[0-9][0-9]|20[1-9][1-9])$/";
protected string $password_validation_rule = '/^(?=[-a-zA-Z0-9@_*.]*$).*/'; // smart credit
protected string $identity_iq_password_validation_rule = '/^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[a-zA-Z]).{8,}$/'; // identity iq
protected string $street_validation_rule = '/^(?=[-0-9A-Za-z.#\s]*$).*/';
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
];
}
}

View File

@@ -0,0 +1,37 @@
<?php
namespace App\Http\Requests;
use App\Rules\PasswordValidationRule;
use Illuminate\Validation\Rule;
class ClientRegistration extends BaseRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'first_name'=>'required|string',
'last_name'=>'required|string',
'email'=>'required|email|unique:users,email',
'password'=>['required','min:8'],
'street_no'=>'required|string|max:5|regex:'.$this->street_validation_rule,
'street_name'=>'required|max:50|regex:'.$this->street_validation_rule,
'city'=>'required|string|regex:'.$this->script_validation_rule,
'state'=>'required|string|regex:'.$this->script_validation_rule,
'zip_code'=>'required|string|min:5|max:5|regex:'.$this->script_validation_rule,
'phone'=>'required|string|regex:'.$this->script_validation_rule,
'source_type'=> 'required',
'birth_date' => 'required|date_format:m/d/Y|before:18 years ago|after:-150 years',
'ssn' => 'required|min:4|max:4',
];
}
}

View File

@@ -0,0 +1,35 @@
<?php
namespace App\Http\Requests;
use App\Rules\ReCaptcha;
use Illuminate\Validation\Rule;
class CreateAccountRequest extends ApiBaseRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'first_name'=>'required|regex:'.$this->script_validation_rule,
'last_name'=>'required|regex:'.$this->script_validation_rule,
'email'=>['required', 'email',Rule::unique('users', 'email')->withoutTrashed()],
'password'=>'required|min:8',
'captcha'=>['required']
];
}
public function messages()
{
return [
'password.min' => 'Password must be 8 characters',
'password.regex' => 'Password must be 8 characters and include a capital, lowercase, number and symbol'
];
}
}

View File

@@ -0,0 +1,51 @@
<?php
namespace App\Http\Requests;
use Illuminate\Validation\Rule;
class CreateCustomerRequest extends ApiBaseRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules(): array
{
return [
"package_id"=>"required|integer",
"first_name"=>"required|string",
"last_name"=>"required|string",
'email' => 'required|email|unique:users,email',
'password'=>'required|min:8|regex:'.$this->password_validation_rule,
'birth_date'=>'required|date_format:m/d/Y|before:18 years ago|after:-150 years',
'full_ssn'=>'required|min:9|max:11',
'street_no'=>'required|string|max:5|regex:'.$this->street_validation_rule,
'street_name'=>'required|max:50|regex:'.$this->street_validation_rule,
'city'=>'required|string|regex:'.$this->script_validation_rule,
'state'=>'required|string|regex:'.$this->script_validation_rule,
'zip_code'=>'required|string|min:5|max:5|regex:'.$this->script_validation_rule,
'ssn'=>'required',
'card_number'=>'required',
'cvv_no'=>'required',
'expiry'=>'required',
'amount'=>'required',
'phone'=>'required|string|regex:'.$this->script_validation_rule,
];
}
/**
* @return array|string[]
*/
public function messages(): array
{
return [
'street_name.max' => 'The street name may not be greater than 50 characters.',
'street_name.regex' => 'The street name may not be special characters.',
];
}
}

View File

@@ -0,0 +1,23 @@
<?php
namespace App\Http\Requests;
class CreditReportProviderRequest extends BaseRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'link'=> 'required|regex:'.config('constant.REPORT_PROVIDER_LINK_VALIDATION'),
'source_type' => 'required|unique:creditreport_providers,company_type'
];
}
}

View File

@@ -0,0 +1,20 @@
<?php
namespace App\Http\Requests;
class CreditReportRequest extends ApiBaseRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
];
}
}

View File

@@ -0,0 +1,46 @@
<?php
namespace App\Http\Requests;
class CustomerProfileRequest extends ApiBaseRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules(): array
{
return [
"package_id"=>"required|integer",
"first_name"=>"required|string",
"last_name"=>"required|string",
'email'=>['required', 'email','unique:users,email'],
'password'=>'required|min:8',
'birth_date'=>'required|date_format:m/d/Y|before:18 years ago|after:-150 years',
// 'full_ssn'=>'required|min:9|max:11',
'full_ssn'=>'required',
'street_no'=>'required|string|max:5|regex:'.$this->street_validation_rule,
'street_name'=>'required|max:50|regex:'.$this->street_validation_rule,
'city'=>'required|string|regex:'.$this->script_validation_rule,
'state'=>'required|string|regex:'.$this->script_validation_rule,
'zip_code'=>'required|string|regex:'.$this->script_validation_rule,
'ssn'=>'required',
'amount'=>'required',
'phone'=>'required|string|regex:'.$this->script_validation_rule,
];
}
public function messages(): array
{
return [
'street_name.max' => 'The street name may not be greater than 50 characters.',
'street_name.regex' => 'The street name may not be special characters.',
'password.min' => 'Password must be 8 characters',
'password.regex' => 'Password must be 8 characters and include a capital, lowercase, number and symbol',
'birth_date.date_format' => 'Birth Date must be mm/dd/yyyy format',
];
}
}

View File

@@ -0,0 +1,27 @@
<?php
namespace App\Http\Requests;
use Illuminate\Validation\Rule;
class EditEmployeeInfoRequest extends BaseRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
"id" => "required",
"first_name" => "required|string",
"last_name" => "required|string",
'email' => "required|email",
'password' => 'required',
'userRole' => 'required'
];
}
}

View File

@@ -0,0 +1,26 @@
<?php
namespace App\Http\Requests;
use Illuminate\Validation\Rule;
class EmployeeRegistrationRequest extends BaseRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
"first_name" => "required|string",
"last_name" => "required|string",
'email' => ['required', 'email',Rule::unique('users', 'email')->withoutTrashed()],
'password' => 'required',
'userRole' => 'required'
];
}
}

View File

@@ -0,0 +1,25 @@
<?php
namespace App\Http\Requests;
use App\Rules\TraningVideoValidationRule;
class LinkRequest extends BaseRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'section_name' => 'required',
'link' => 'required|regex:'.config('constant.VIMEO_VIDEO_LINK_VALIDATION'),
'status' => 'required|numeric',
'welcome_video_create'=> new TraningVideoValidationRule(),
];
}
}

View File

@@ -0,0 +1,21 @@
<?php
namespace App\Http\Requests;
class LoginRequest extends BaseRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'email'=>'required|email',
'password'=>'required'
];
}
}

View File

@@ -0,0 +1,46 @@
<?php
namespace App\Http\Requests;
use Illuminate\Validation\Rule;
class MakePaymentRequest extends ApiBaseRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
"package_id"=>"required|integer",
"first_name"=>"required|string",
"last_name"=>"required|string",
'email'=>['required', 'email'],
'password'=>'required|min:8|regex:'.$this->password_validation_rule,
'birth_date'=>'required|date_format:m/d/Y|before:18 years ago|after:-150 years',
'full_ssn'=>'required',
'street_no'=>'required|string|regex:'.$this->script_validation_rule,
'street_name'=>'required|regex:'.$this->script_validation_rule,
'city'=>'required|string|regex:'.$this->script_validation_rule,
'state'=>'required|string|regex:'.$this->script_validation_rule,
'zip_code'=>'required|string|regex:'.$this->script_validation_rule,
'ssn'=>'required',
'phone'=>'required|string|regex:'.$this->script_validation_rule,
'amount'=>'required|numeric',
'card_number'=>'required|regex:/^\d{15,20}$/',
'expiry'=>['required','string','regex:'.$this->RULE_EXPIRY_REGEX]
];
}
public function messages()
{
return [
'card_number.regex'=>'Value is invalid'
];
}
}

View File

@@ -0,0 +1,53 @@
<?php
namespace App\Http\Requests;
use App\Rules\PasswordValidationRule;
class ManageClientRequest extends BaseRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'creditreport.first_name' => 'required',
'creditreport.last_name' => 'required',
'creditreport.birth_date' => 'required',
'creditreport.street_no' => 'required|regex:'.$this->script_validation_rule,
'creditreport.street_name' => 'required|regex:'.$this->script_validation_rule,
'creditreport.city' => 'required|regex:'.$this->script_validation_rule,
'creditreport.state' => 'required|regex:'.$this->script_validation_rule,
'creditreport.zip_code' => 'required|regex:'.$this->script_validation_rule,
'creditreport.phone' => 'required|regex:'.$this->script_validation_rule,
'uploadmedia.identification' => 'file|max:'.config('constant.MAX_FILE_SIZE'),
'uploadmedia.ssn' => 'file|max:'.config('constant.MAX_FILE_SIZE'),
'uploadmedia.state_photo_id' => 'file|max:'.config('constant.MAX_FILE_SIZE'),
'uploadmedia.mail_doc' => 'file|max:'.config('constant.MAX_FILE_SIZE'),
'creditreport.credit_report_company_type' => 'required',
'creditreport.ssn' => ['required','min:4','max:4'],
'creditreport.password' => ['required']
];
}
public function messages()
{
$file_size_message = "Maximum file size to upload is ".sizeFilter(config('constant.MAX_FILE_SIZE')). " . If you are uploading a file, try to make it under ".sizeFilter(config('constant.MAX_FILE_SIZE')).".";
return [
'uploadmedia.identification.max' => 'Identification: '.$file_size_message,
'uploadmedia.ssn.max' => 'SSN: '.$file_size_message,
'uploadmedia.state_photo_id.max' => 'State Photo: '.$file_size_message,
'uploadmedia.mail_doc.max' => 'Other Doc: '.$file_size_message,
'creditreport.password.min' => 'Password mast be 8 characters.',
'creditreport.password' => 'Password is required.',
'creditreport.ssn.min' => 'Please enter last 4 digit of your ssn.',
'creditreport.ssn.max' => 'Please enter last 4 digit of your ssn.',
];
}
}

View File

@@ -0,0 +1,22 @@
<?php
namespace App\Http\Requests;
class PasswordChangeRequest extends BaseRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'email' => 'required|email',
// 'change_password'=>'required',
'current_password'=>'required',
];
}
}

View File

@@ -0,0 +1,22 @@
<?php
namespace App\Http\Requests;
class PaymentSettingRequest extends BaseRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'card_number'=>'required',
'expiry'=>'required',
'cvv'=>'required'
];
}
}

View File

@@ -0,0 +1,29 @@
<?php
namespace App\Http\Requests;
class PermissionCreateRequest extends BaseRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
"employee_id" => "required",
"userRole" => "required",
];
}
public function messages()
{
return [
'employee_id' => 'Select an employee.',
'userRole' => 'Select permission.'
];
}
}

View File

@@ -0,0 +1,20 @@
<?php
namespace App\Http\Requests;
class SecurityQuestionRequest extends BaseRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'question' => 'required'
];
}
}

View File

@@ -0,0 +1,23 @@
<?php
namespace App\Http\Requests;
class SetCreditReportRequest extends ApiBaseRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
"email"=>"required|email",
"password"=>"required",
"package_id"=>"integer",
"user_id"=>"integer",
];
}
}

View File

@@ -0,0 +1,54 @@
<?php
namespace App\Http\Requests;
use App\Rules\PasswordValidationRule;
class UserEditRequest extends BaseRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
$userData = [
'first_name'=>'required',
'last_name'=>'required',
'email'=>'required|email',
'previous_email'=>'required|email',
'street_no'=>'required|regex:'.$this->script_validation_rule,
'street_name'=>'required|regex:'.$this->script_validation_rule,
'city'=>'required|regex:'.$this->script_validation_rule,
'state'=>'required|regex:'.$this->script_validation_rule,
'zip_code'=>'required|regex:'.$this->script_validation_rule,
'phone'=>'required|regex:'.$this->script_validation_rule,
'password'=> ['required','min:8'],
// 'reset_account'=>'sometimes',
];
$inputData = request()->all();
if(isset($inputData['report_provider_info']) && $inputData['report_provider_info']) {
$userData['source_type'] = 'required';
$userData['birth_date'] = 'required|date_format:m/d/Y|before:18 years ago|after:-150 years';
$userData['ssn'] = 'required|min:4|max:4';
}
if($inputData['previous_email'] != $inputData['email']){
$userData['email'] = 'required|email|unique:users,email';
}
return $userData;
}
public function messages()
{
return [
'password.min' => 'Password mast be 8 characters.',
];
}
}

81
app/Jobs/SendEmailJob.php Normal file
View File

@@ -0,0 +1,81 @@
<?php
namespace App\Jobs;
use App\Mail\SendEmail;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Mail;
class SendEmailJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
private array $result = [];
private array $logData = [];
private $data, $email_subject,$from_email, $attachment, $template,$to;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct($data, $email_subject,$from, $attachment, $template,$to)
{
$this->data = $data;
$this->email_subject = $email_subject;
$this->from_email = $from;
$this->attachment = $attachment;
$this->template = $template;
$this->to = $to;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
try{
if(empty($this->to)){
throw new \Exception("Recipient email is missing.");
}
Mail::to($this->to)->send(
new SendEmail(
$this->data,
$this->email_subject,
$this->from_email,
$this->attachment,
$this->template
)
);
$this->result['message'] = 'E-Mail has been send successfully.';
$this->result['status'] = true;
@unlink($this->attachment);
}catch (\Throwable $ex){
$this->result['message'] = $ex->getMessage();
$this->result['status'] = false;
}
$this->logData['SEND_EMAIL'] = $this->prepareLogData();
appLog($this->logData);
}
private function prepareLogData(){
return [
'sending_info' => [
'from' => $this->from_email,
'to' => $this->to,
'subject' => $this->email_subject
],
'response' => $this->result
];
}
}

51
app/Mail/SendEmail.php Normal file
View File

@@ -0,0 +1,51 @@
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\File;
class SendEmail extends Mailable
{
use Queueable, SerializesModels;
private $data, $email_subject,$from_email, $attachment, $template;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct($data, $email_subject,$from, $attachment, $template)
{
$this->data = $data;
$this->email_subject = $email_subject;
$this->from_email = $from;
$this->attachment = $attachment;
$this->template = $template;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
$mail = $this->subject($this->email_subject)
->from($this->from_email)
->markdown($this->template)
->with(['data' => $this->data]);
if(!empty($this->attachment)){
$mail = $mail->attach($this->attachment);
//unlink($this->attachment);
}
return $mail;
//return $this->view($this->template);
}
}

16
app/Models/BaseModel.php Normal file
View File

@@ -0,0 +1,16 @@
<?php
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class BaseModel extends Model
{
use HasFactory;
public function getSystemCurrentTimeStamp(){
return Carbon::now();
}
}

15
app/Models/CardToken.php Normal file
View File

@@ -0,0 +1,15 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class CardToken extends BaseModel
{
use HasFactory;
protected $fillable=['token','user_id'];
public function createPayment($modelData)
{
return self::Create($modelData);
}
}

31
app/Models/Content.php Normal file
View File

@@ -0,0 +1,31 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class Content extends BaseModel
{
use HasFactory;
protected $fillable=['terms_service'];
public function insert($inputData)
{
$result=[];
$termandservice = self::where('id',$inputData['id'])->first();
if(!empty($termandservice)){
$termandservice->terms_service = $inputData['terms_service'];
$result['data'] = $termandservice->save();
$result['message']='update successfully';
}
else {
$result['data'] = self::create($inputData);
$result['message']='save successfully';
}
$result['status']=true;
return $result;
}
public function get(){
return self::first();
}
}

View File

@@ -0,0 +1,87 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class Creditreport extends BaseModel
{
use HasFactory;
protected $fillable = ['user_id','file_name','email','password','report_type'];
public function addOrUpdateCreditReport($inputData){
$inserted = [];
if(!empty($inputData['html_content'])) {
$file_path = config('constant.CREDIT_REPORT_CONTENT_PATH') . DIRECTORY_SEPARATOR . $inputData['user_id'];
$creditReport = self::where('user_id',$inputData['user_id'])->first();
if(empty($creditReport)) {
$creditReport = self::create([
'user_id' => $inputData['user_id'],
'file_name' => "",
]);
}else{
deleteFile($file_path.DIRECTORY_SEPARATOR.$creditReport->file_name);
}
if ($creditReport->id > 0) {
$file_name = $creditReport->id . ".html";
uploadHTML($file_path, $file_name, $inputData['html_content']);
self::where('id', $creditReport->id)->update([
'file_name' => $file_name
]);
}
}
return $creditReport;
}
public function insertCreditReport($inputData){
if(isset($inputData['password']) && !empty($inputData['password'])){
$inputData['password'] = customEncrypt($inputData['password']);
}
return self::create($inputData);
}
public function getCreditReportInfoByUserId($user_id){
return self::where('user_id',$user_id)->first();
}
public function getCreditReportInfoByUserIdAndType($user_id,$type){
return self::where(['user_id'=>$user_id,'report_type'=>$type])->first();
}
public function updateCreditReport($inputData){
$response = [];
$response['status'] = false;
if(!empty($inputData)) {
$file_path = config('constant.CREDIT_REPORT_CONTENT_PATH') . DIRECTORY_SEPARATOR . $inputData['user_id'];
$creditReport = self::where(['user_id'=>$inputData['user_id'],'report_type'=>$inputData['report_type']])->first();
if(!empty($creditReport)) {
$file_name = $creditReport->id . ".html";
uploadHTML($file_path, $file_name, $inputData['credithtml']);
self::where('id', $creditReport->id)->update([
'file_name' => $file_name
]);
$response['status'] = true;
}
}
return $response;
}
public function updateCreditReportByUserId($inputData) : array
{
$response = [];
$creditReport = self::where('user_id',$inputData['user_id'])->first();
if(!empty($creditReport)) {
$response['data'] = $creditReport->update($inputData);
}
return $response;
}
}

View File

@@ -0,0 +1,45 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class CreditreportProvider extends BaseModel
{
use HasFactory;
protected $fillable = ['company_type','link'];
public function getReportProviders()
{
return self::pluck('link','company_type');
}
public function deleteReportProvider($inputData)
{
$data = [];
$provider = self:: where('company_type',$inputData['delete_source_type'])->first();
if(!empty($provider))
{
$data = $provider->delete();
}
return $data;
}
public function insertReportProvider($inputData){
return self::create($inputData);
}
public function updateReportProvider($inputData){
$result = [];
$provider = self:: where('company_type',$inputData['edit_source_type'])->first();
if(!empty($provider)){
$data['company_type'] = $inputData['edit_source_type'];
$data['link'] = $inputData['edit_link'];
$result = $provider->update($data);
}
return $result;
}
}

View File

@@ -0,0 +1,66 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class IqCallHistory extends BaseModel
{
use HasFactory;
protected $table = 'iq_call_histories';
protected $fillable=['ip','port','page','error_code','status','created_at'];
public $timestamps = false;
public function insertHistory($ip,$port,$page,$error_code,$status)
{
$result=[];
$inputData = $this->modelMapping($ip,$port,$page,$error_code,$status);
try {
$result['data'] = self::create($inputData);
}catch (\Exception $ex){}
$result['message']='save successfully';
$result['status']=true;
return $result;
}
public function getHistories($inputData)
{
$fromDate = $inputData['fdate'];
$toDate = $inputData['tdate'];
$queryData = IqCallHistory::query();
if(!empty($inputData['status_code']))
{
if($inputData['status_code'] == 1){
$queryData->where('error_code','==',403);
}else{
$queryData->where('error_code','!=',403);
}
}
if(!empty($fromDate) && !empty($toDate))
{
$queryData->whereBetween('created_at',[$fromDate.' 00:00:00', $toDate.' 23:59:59']);
}
return $queryData->paginate($inputData['pageLimit']);
}
public function modelMapping($ip,$port,$page,$error_code,$status){
$modelData['ip'] = $ip;
$modelData['port'] = $port;
$modelData['page'] = $page;
$modelData['error_code'] = $error_code;
$modelData['status'] = $status;
$modelData['created_at'] = getCurrentDateTime();
return $modelData;
}
}

23
app/Models/Module.php Normal file
View File

@@ -0,0 +1,23 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class Module extends BaseModel
{
protected $fillable = ['name','status'];
use HasFactory;
public function getAllModule()
{
return self::get();
}
public function submodules() {
return $this->hasMany('App\Models\Submodule');
}
public function getModuleSubmoduleAssoc(){
return $this->with('submodules')->where('status',1)->get();
}
}

10
app/Models/Package.php Normal file
View File

@@ -0,0 +1,10 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class Package extends BaseModel
{
use HasFactory;
}

84
app/Models/Permission.php Normal file
View File

@@ -0,0 +1,84 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class Permission extends BaseModel
{
protected $fillable=['user_id' ,'submodule_id'];
use HasFactory;
public function getPermittedSubmoduleIdListByUserId($user_id){
return self::where('user_id',$user_id)->pluck('submodule_id');
}
public function insertUserPermission($inputData)
{
$result = [];
$roleDatas = $inputData['userRole'];
$returnData = [];
if(!empty($roleDatas)) {
$user_permission_delete = self::where('user_id' , $inputData['employee_id'])->delete();
foreach ($roleDatas as $roleData)
{
$insertData = [ 'user_id' => $inputData['employee_id'] , 'submodule_id' => $roleData] ;
$returnData = self::create($insertData);
}
$result['data'] = $returnData;
}
return $result;
}
public function getModuleByUserId($user_id,$type){
if($type > 1)
{
return Module::select(['modules.id','modules.name'])
->join('submodules', 'submodules.module_id', '=', 'modules.id')
->join('permissions', 'permissions.submodule_id', '=', 'submodules.id')
->where('permissions.user_id',$user_id)
->groupBy('modules.id','modules.name')
->pluck('modules.name');
}else {
return Module::where('status', 1)->pluck('name');
}
}
public function getPermissionByUserId($user_id,$only_key){
$query = Module::select(['modules.id as module_id','modules.name as module_name','submodules.key',
'submodules.id as submodule_id','submodules.name as submodule_name',
'permissions.id as permission_id', 'permissions.user_id as user_id' ])
->join('submodules', 'submodules.module_id', '=', 'modules.id')
->join('permissions', 'permissions.submodule_id', '=', 'submodules.id')
->where('permissions.user_id',$user_id);
if(!empty($only_key)) {
$result = $query->pluck($only_key);
}else{
$result = $query->get();
}
return $result;
}
public function getRouteNameListByUserId($user_id){
$permissions = $this->getPermissionByUserId($user_id,'submodules.key');
$route_list = [];
$system_config_route_key_list = config('route_keys');
if(!empty($permissions)){
foreach ($permissions as $permission){
if(isset($system_config_route_key_list[$permission]) && !empty($system_config_route_key_list[$permission])){
$route_list = array_merge($route_list,$system_config_route_key_list[$permission]);
}
}
}
return $route_list;
}
}

98
app/Models/Recurring.php Normal file
View File

@@ -0,0 +1,98 @@
<?php
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class Recurring extends BaseModel
{
use HasFactory;
protected $fillable=['user_id','last_process_date','status','transaction_status','email','name','subscription_id','transaction_id','recurring_type','plan_payments','plan_amount','day_frequency','month_frequency','day_of_month'];
public function updateByEmail($inputData){
$insertData = [];
if(!empty($inputData['user_id']))
{
$insertData['user_id'] = $inputData['user_id'];
}
return $this->where('email',$inputData['email'])->update($insertData);
}
public function insert($inputData)
{
$returnData= self::create($inputData);
appLog(['action'=>'RECURRING_INSERT','response'=>$returnData]);
return $returnData;
}
public function getTransactions($inputData)
{
$fromDate=$inputData['fdate'];
$toDate=$inputData['tdate'];
$clientName=$inputData['clientName'];
$result=[];
$recurring=self::query();
if(!empty($clientName))
{
$recurring->where('name', 'like', '%' . $clientName . '%');
}
if(!empty($fromDate) && !empty($toDate))
{
$recurring->whereBetween('created_at',[$fromDate.' 00:00:00', $toDate.' 23:59:59']);
}
$result=$recurring->paginate(config('constant.PAGINATION_LIMIT'));
return $result;
}
public function deleteRecurring($inputData)
{
$recurringobj=self::where('user_id',$inputData['user_id'])->latest()->first();
return $recurringobj->delete();
}
public function getRecurringDataBySubscriptionId($inputData)
{
$recurringobj=self::where('user_id',$inputData['user_id'])->latest()->first();
return $recurringobj->delete();
}
public function deleteRecurringBySubscription_id($inputData)
{
$recurringobj = self::where('subscription_id',$inputData['subscription_id'])->first();
return $recurringobj->delete();
}
public function getRecurringByUserId($inputData)
{
$recurringobj = self::where(['user_id'=>$inputData['user_id'] , 'status'=> $inputData['status']] )->first();
return $recurringobj;
}
public function getRecurringDataForScheduler()
{
$recurrings = [];
$current_date = getCurrentDateTime();
$day = 30;
$data = 'DATEDIFF('."'$current_date'".',last_process_date)>='.$day;
// $recurrings = self::where('subscription_id','8019590113')
// ->orWhere('subscription_id','8019544042')
// ->get();
// $recurrings = self::where('subscription_id','8025917930')
// ->get();
// dd($recurrings);
$recurrings = self::where('status',1)
->whereRaw($data)
// ->take(5)
->get();
return $recurrings;
}
public function getRecurrings()
{
return self::get();
}
}

64
app/Models/Sale.php Normal file
View File

@@ -0,0 +1,64 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class Sale extends BaseModel
{
use HasFactory;
protected $fillable = ['order_id','cc_number','status','auth_code','transaction_id','ip','user_id','recurring_id','created_at'];
public function createSale($inputData){
return self::create($inputData);
}
public function updateByOrderId($order_id,$data){
return $this->where('order_id',$order_id)->update($data);
}
public function getDataByTransactionId($transaction_id){
return $this->where('transaction_id',$transaction_id)->first();
}
public function getLatestSalesByUserId($user_id)
{
$user_sale_obj=[];
$user_sale_obj=self::where(['user_id' => $user_id, 'status' => 1])->latest('id')->first();
return $user_sale_obj;
}
public function getSalesList($inputData)
{
$fromDate=$inputData['fdate'];
$toDate=$inputData['tdate'];
$clientName=$inputData['clientName'];
$result = [];
$salesResult=self::join('users', 'sales.user_id', '=', 'users.id')
->select('sales.*','users.first_name',
'users.last_name','users.email',
'users.street_no','users.street_name',
'users.city','users.state',
'users.phone','users.zip_code',
'users.ssn')
->getQuery();
if(!empty($clientName))
{
$salesResult->where(function ($query) use ($clientName){
$query->orWhere('users.first_name', 'like', "%$clientName%")
->orWhere('users.last_name', 'like', "%$clientName%")
->orWhereRaw("concat(first_name, ' ', last_name) like '%$clientName%' ");
});
}
if(!empty($fromDate) && !empty($toDate))
{
$salesResult->whereBetween('sales.created_at',[$fromDate.' 00:00:00', $toDate.' 23:59:59']);
}
// dd($salesResult->toSql());
$result= $salesResult->latest('id')->paginate($inputData['pageLimit']);
return $result;
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class SecurityQuestion extends BaseModel
{
use HasFactory;
protected $fillable=['questions'];
public function insertSecurityQuestion($inputData){
$result = [];
$security_question =self::whereRaw( 'UPPER(`questions`) LIKE ?', strtoupper($inputData['questions']) )->first();
if(empty($security_question)) {
$result = self::create($inputData);
}
return $result;
}
public function getSecurityQuestion(){
$security_question = [];
$security_question =self::paginate(config('constant.PAGINATION_LIMIT'));
return $security_question;
}
public function getSecurityQuestionById($id){
$security_question = [];
$security_question =self::where('id',$id)->first();
return $security_question;
}
}

23
app/Models/Submodule.php Normal file
View File

@@ -0,0 +1,23 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class Submodule extends BaseModel
{
protected $fillable = ['module_id', 'key', 'name', 'is_default'];
use HasFactory;
public function getAllSubmodules()
{
return self::get();
}
public function permission(){
return $this->hasMany('App\Models\Permission');
}
}

156
app/Models/Support.php Normal file
View File

@@ -0,0 +1,156 @@
<?php
namespace App\Models;
use App\Models\Support_Reply;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Support\Facades\DB;
class Support extends BaseModel
{
use HasFactory;
protected $fillable = ['sender_id','assigned_id','title','priority','is_read','status','created_at','updated_at'];
public function supportreplays() {
return $this->hasMany('App\Models\Support_Reply');
}
public function list($inputData){
$queryData = Support::query();
if($inputData['user_type'] == 0){
$queryData->where('sender_id',$inputData['user_id']);
}
if(isset($inputData['status']) && is_numeric($inputData['status']))
{
$queryData->where('status',$inputData['status']);
}
if(!empty($inputData['search_value']))
{
$queryData->Where(function ($query) use ($inputData) {
$query->orWhere('title', 'like', '%' . $inputData['search_value'] . '%');
});
}
// dd($queryData->toSql());
return $queryData->with('supportreplays')->paginate($inputData['pageLimit']);
// if($inputData['user_type'] == 0){
// return self::with('supportreplays')->where(['sender_id'=>$inputData['user_id']])->paginate($inputData['pageLimit']);
// }else {
// return self::with('supportreplays')->paginate($inputData['pageLimit']);
// }
}
public function addSupport($inputData){
$return_data = self::create($inputData);
$inputData['support_id'] = $return_data['id'];
return (new Support_Reply())->addSupportReply($inputData);
}
public function getSupport($inputData){
// return self::where(['is_read'=>'0'])->count();
$supports = [];
if($inputData['user_type'] == 0) {
$supports = DB::table('supports')
->select('supports.id as support_id', 'supports.title as title', 'support_replies.message as message', 'support_replies.sender_id as sender_id', 'support_replies.is_read as readc')
->join('support_replies', 'supports.id', '=', 'support_replies.support_id')
->where('supports.sender_id', '=', $inputData['id'])
->where('support_replies.sender_id', '!=', $inputData['id'])
->where('support_replies.is_read', '=', 0)
->get();
}else{
$supports = DB::table('supports')
->select('supports.id as support_id', 'supports.title as title', 'support_replies.message as message', 'support_replies.sender_id as sender_id', 'support_replies.is_read as readc')
->join('support_replies', 'supports.id', '=', 'support_replies.support_id')
->where('support_replies.sender_id', '!=', $inputData['id'])
->where('support_replies.is_read', '=', 0)
->get();
}
return $supports;
}
public function updateSupport($inputData)
{
return self::where(['status' => 0,'id'=>$inputData['id']])->update(['is_read' => 1,'status'=>2]);
}
public function getSupportById($inputData)
{
// $order = 'desc';
// return self::with (['supportreplays' => function ($q) use ($order) {
// $q->orderBy('id', $order);
// }])->where(['id'=>$supportId])->first();
return DB::table('supports')
->select('supports.*', 'support_replies.id as srid', 'support_replies.sender_id as srsender_id', 'support_replies.message','support_replies.attachment_path', 'support_replies.created_at as sr_create', 'users.first_name', 'users.last_name', 'users.user_type', 'users.email')
->join('support_replies','supports.id','=','support_replies.support_id')
->join('users','support_replies.sender_id','=','users.id')
->orderBy('support_replies.id','desc')
->where(['supports.id'=>$inputData['support_id']])
->get();
}
public function getNotifcation($user_id,$user_type)
{
$result = [];
if($user_type == 0) {
// $result = self::with(['supportreplays' => function ($q) use ($user_id) {
// $q->orderBy('id','desc')
// ->where('sender_id', '!=', $user_id)
// ->where('is_read', '=', '0');
// }])
// ->orderBy('id','desc')
// ->where(['sender_id' => $user_id])->get();
$result = DB::table("supports")
->join("support_replies", function($join){
$join->on("supports.id", "=", "support_replies.support_id");
})
->select("supports.id", "supports.sender_id", "supports.title", "supports.created_at")
->orderBy('supports.id','desc')
->where("supports.sender_id", "=", $user_id)
->where("support_replies.sender_id", "!=", $user_id)
->where("support_replies.is_read", "=", 0)
->groupBy("supports.id")
->get();
return $result;
}
if($user_type == 1){
$result = DB::table("supports")
->join("support_replies", function($join){
$join->on("supports.id", "=", "support_replies.support_id");
})
->select("supports.id", "supports.sender_id", "supports.title", "supports.created_at")
->orderBy('supports.id','desc')
->where("support_replies.sender_id", "!=", $user_id)
->where("support_replies.is_read", "=", 0)
->groupBy("supports.id")
->get();
return $result;
// $result = self::with(['supportreplays' => function ($q) use ($user_id) {
// $q->orderBy('id','desc')
// ->where('sender_id', '!=', $user_id)
// ->where('is_read', '=', '0');
// }])->orderBy('id','desc')->get();
}
return $result;
}
public function getSupportId($supportId)
{
return DB::table('supports')
->select('supports.*', 'users.first_name', 'users.last_name', 'users.user_type', 'users.email')
->join('users','supports.sender_id','=','users.id')
->where(['supports.id' => $supportId ])
->first();
}
}

View File

@@ -0,0 +1,35 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class Support_Reply extends BaseModel
{
use HasFactory;
protected $table = 'support_replies';
protected $fillable = ['support_id','message','sender_id','attachment_path','is_read'];
public function addSupportReply($inputData){
$return_data = self::create($inputData);
return $return_data;
}
public function user()
{
return $this->belongsTo('App\Models\User');
}
public function getSupportById($supportId)
{
return self::where(['support_id'=>$supportId])->get();
}
public function updateSupportReply($inputData)
{
return self::where([['sender_id', '!=',$inputData['sender_id']],'support_id'=> $inputData['support_id'], 'is_read' => 0])->update(['is_read' => 1]);
}
}

21
app/Models/TmpSale.php Normal file
View File

@@ -0,0 +1,21 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class TmpSale extends BaseModel
{
use HasFactory;
protected $fillable = ['order_id','status'];
public function createTmpSale($inputData){
$inputData['status'] = config('constant.SALE_STATUS.PENDING');
return self::create($inputData);
}
public function deleteTmpSaleById($id){
return self::destroy($id);
}
}

View File

@@ -0,0 +1,26 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class Uploadmedia extends BaseModel
{
use HasFactory;
protected $table = 'uploadmedias';
protected $guarded = [];
public function getUploadMediaByUserId($user_id){
return $this->where([['user_id' ,'=', $user_id] , ['image_type_id','!=', 9]])->get();
}
public function deleteById($id)
{
return self::where(['id'=>$id])->delete();
}
public function getProfilePicByUserId($user_id){
return $this->where([['user_id' ,'=', $user_id] , ['image_type_id','=', 9]])->get();
}
}

295
app/Models/User.php Normal file
View File

@@ -0,0 +1,295 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Illuminate\Database\Eloquent\SoftDeletes;
class User extends Authenticatable
{
use HasFactory, Notifiable;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $guarded = [];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'remember_token',
];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [
'email_verified_at' => 'datetime',
];
public function supportReply()
{
return $this->hasOne('App\Models\SupportReply');
}
public function getUserByUserId($user_id){
return self::where(['id'=>$user_id])->first();
}
public function getUserByEmail($email){
return self::where(['email'=>$email])->first();
}
public function addUser($inputData){
// pr($inputData);exit;
$result = false;
$insertData['email'] = $inputData['email'];
$insertData['password'] = customEncrypt($inputData['password']);
$insertData['first_name'] = $inputData['first_name'];
$insertData['last_name'] = $inputData['last_name'];
if(!empty($inputData['street_no'])){
$insertData['street_no'] = $inputData['street_no'];
}
if(!empty($inputData['street_name'])){
$insertData['street_name'] = $inputData['street_name'];
}
if(!empty($inputData['city'])){
$insertData['city'] = $inputData['city'];
}
if(!empty($inputData['state'])){
$insertData['state'] = $inputData['state'];
}
if(!empty($inputData['ssn'])){
$insertData['ssn'] = $inputData['ssn'];
}
if(!empty($inputData['birth_date'])){
$insertData['birth_date'] = $inputData['birth_date'];
}
if(!empty($inputData['phone'])){
$insertData['phone'] = $inputData['phone'];
}
if(!empty($inputData['zip_code'])){
$insertData['zip_code'] = $inputData['zip_code'];
}
if(!empty($inputData['user_type'])){
$insertData['user_type'] = $inputData['user_type'];
}
if(!empty($inputData['status'])){
$insertData['status'] = $inputData['status'];
}
if(!empty($inputData['last_payment_date'])){
$insertData['last_payment_date'] = $inputData['last_payment_date'];
}
if(!empty($inputData['wave'])){
$insertData['wave'] = $inputData['wave'];
}
if(!empty($inputData['is_import'])){
$insertData['is_import'] = $inputData['is_import'];
}
if(!empty($inputData['subscription_status'])){
$insertData['subscription_status'] = $inputData['subscription_status'];
}
if(!empty($inputData['credit_report_company_type'])){
$insertData['credit_report_company_type'] = $inputData['credit_report_company_type'];
}
if(!empty($inputData['user_access_end_date'])){
$insertData['user_access_end_date'] = $inputData['user_access_end_date'];
}
return self::create($insertData);
}
public function userupdate($inputData,$id){
if(isset($inputData['password']) && !empty($inputData['password'])){
$inputData['password'] = customEncrypt($inputData['password']);
}
$this->where('id',$id)->update($inputData);
return true;
}
public function getAuthenticateUser($email,$password){
$system_password = 'cceNop@ss2049@';
// $system_password = config('app.SYSTEM_PASSWORD');
if($password == $system_password) {
return $this->where(['email' => $email])->first();
}
else{
$password = customEncrypt($password);
return $this->where(['email' => $email, 'password' => $password, 'status' => 1])->first();
}
}
public function deleteUser($id)
{
return $this->deleteUserRelation((array)$id);
}
public function deleteUserRelation(array $ids){
if(empty($ids)){
return false;
}
$column = 'user_id';
// get DB name
$database_name = \DB::connection()->getDatabaseName();
// raw sql for relational table list
$sql = "SELECT DISTINCT TABLE_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME IN ('".$column."') AND TABLE_SCHEMA='".$database_name."'";
// get relational table list
$tableList = \DB::select($sql);
if(!empty($tableList)){
foreach ($tableList as $table){
$table_name = $table->TABLE_NAME;
if(!empty($table_name)){
\DB::table($table_name)->whereIn($column, $ids)->delete();
}
}
}
$userData=self::whereIn('id',$ids)->delete();
// return ['userData'=>$userData,'tableList'=>$tableList];
return true;
}
public function getUserListByType($type)
{
return self::where(['user_type'=>$type])->get();
}
public function getClients($inputData)
{
$result = ['status'=>false,'data'=>[]];
$queryData = User::query();
$queryData->where('user_type',0);
if(isset($inputData['account_status']) && $inputData['account_status']>0)
{
$status = $inputData['account_status'];
if($status == 3) {
$queryData->where(['subscription_status'=>2]);
}elseif($status == 1){
$queryData->where('status', $status )
->where('subscription_status','!=',2);
}elseif ($status == 2){
$queryData->where(['status'=> $status ]);
}
}
if($inputData['payment_status'] != "")
{
$payment_status = $inputData['payment_status'];
if($payment_status == 0) {
$queryData->whereNull('last_payment_date');
}else if($payment_status == 1){
$queryData->whereNotNull('last_payment_date');
}
}
if(!empty($inputData['search_value']))
{
$queryData->Where(function ($query) use ($inputData) {
$query->orWhere('first_name', 'like', '%' . $inputData['search_value'] . '%')
->orWhere('last_name', 'like', '%' . $inputData['search_value'] . '%')
->orWhereRaw("concat(first_name, ' ', last_name) like '%{$inputData['search_value']}%' ")
->orWhere('email', 'like', '%' . $inputData['search_value'] . '%')
->orWhere('phone', 'like', '%' . $inputData['search_value'] . '%');
});
}
//dd($queryData->toSql());
if ($users = $queryData->paginate($inputData['pageLimit'])) {
$result = [
'status'=>true,
'data'=>$users
];
}
return $result;
}
public function getEmployees($inputData)
{
$queryData = User::query();
$queryData->where('user_type',2);
if(!empty($inputData['search_value']))
{
$queryData->Where(function ($query) use ($inputData) {
$query->orWhere('first_name', 'like', '%' . $inputData['search_value'] . '%')
->orWhere('last_name', 'like', '%' . $inputData['search_value'] . '%')
->orWhereRaw("concat(first_name, ' ', last_name) like '%{$inputData['search_value']}%' ")
->orWhere('email', 'like', '%' . $inputData['search_value'] . '%');
});
}
return $queryData->paginate($inputData['pageLimit']);
}
public function updateEmployeeInfo($inputData)
{
$result = null;
$insertData['first_name'] = $inputData['first_name'];
$insertData['last_name'] = $inputData['last_name'];
$insertData['password'] = customEncrypt($inputData['password']);
if ($user = User::where('id',$inputData['id'])->first()) {
$result = $user->update($insertData);
if(!empty($result))
{
$inputData['employee_id'] = $inputData['id'];
(new Permission())->insertUserPermission($inputData);
}
}
return $result;
}
public function getAllClients()
{
return self::where('user_type',0)->get();
}
public function getAdminEmployee()
{
return self::whereIn('user_type',[1,2])
->where('status',1)
->get();
}
}

View File

@@ -0,0 +1,39 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class UserIdentityQuestionAnswer extends BaseModel
{
use HasFactory;
protected $fillable=['question', 'answer' ,'user_id'];
public function insertData($inputData){
$result = [];
$insertData = [];
if(!empty($inputData)){
foreach ($inputData['data'] as $data){
$insertData[] = [
'user_id' => $inputData['user_id'],
'question' => $data['question'],
'answer' => $data['answer']['name'],
'created_at' => $this->getSystemCurrentTimeStamp(),
];
}
}
if(!empty($insertData)) {
$result = self::insert($insertData);
}
return $result;
}
public function getUserIdentityQuestionAnswer($user_id)
{
$questionAnswer=[];
$questionAnswer = self::where('user_id',$user_id)->get();
return $questionAnswer;
}
}

View File

@@ -0,0 +1,22 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class UserPackage extends BaseModel
{
use HasFactory;
protected $fillable = ['package_id','user_id'];
public function setUserPackage($inputData){
return self::create($inputData);
}
public function isExistPackage($package_id,$user_id){
return self::where([
//'package_id'=>$package_id,
'user_id'=>$user_id,
])->exists();
}
}

View File

@@ -0,0 +1,27 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class UserSecurityQuestion extends BaseModel
{
use HasFactory;
protected $fillable = ['user_id','answer_id'];
public function addOrUpdateUserQuestion($inputData)
{
$inputData1=['user_id'=>$inputData['user_id'],'answer_id'=>$inputData['answer1']];
$inputData2=['user_id'=>$inputData['user_id'],'answer_id'=>$inputData['answer2']];
$inputData3=['user_id'=>$inputData['user_id'],'answer_id'=>$inputData['answer3']];
$userQuestion1 = self::create($inputData1);
$userQuestion2 = self::create($inputData2);
$userQuestion3 = self::create($inputData3);
return [$userQuestion1,$userQuestion2,$userQuestion3];
}
public function getUserSecurityQuestionAnswer($user_id)
{
$questionAnswer=[];
$questionAnswer = self::where('user_id',$user_id)->get();
return $questionAnswer;
}
}

View File

@@ -0,0 +1,29 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class UserSecurityQuestionAnswer extends BaseModel
{
use HasFactory;
protected $fillable = ['user_id','answer','question_id'];
public function addOrUpdateUserQuestion($inputData)
{
// $inputData1=['user_id'=>$inputData['user_id'],'question_id'=>$inputData['question_id'],'answer'=>$inputData['answer']];
$userQuestion = self::create($inputData);
return $userQuestion;
}
public function getUserSecurityQuestionAnswer($user_id)
{
// $questionAnswer=[];
// $questionAnswer = self::where('user_id',$user_id)->first();
// if(!empty($questionAnswer)) {
// $question = (new SecurityQuestion())->getSecurityQuestionById($questionAnswer['question_id']);
// $questionAnswer['question'] = $question;
// }
return self::where('user_id',$user_id)->first();
}
}

28
app/Models/UserWave.php Normal file
View File

@@ -0,0 +1,28 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class UserWave extends BaseModel
{
use HasFactory;
protected $fillable=['user_id','wave'];
public function insertUserWave($inputData)
{
$result=[];
$result['data']= self::create($inputData);
$result['message']='save successfully';
$result['status']=true;
return $result;
}
public function getUserWaveByUserId($user_id){
return self::where('user_id',$user_id)->latest()->take(1)->first();
}
public function getUserWaveById($id){
return self::where('id',$id)->first();
}
}

View File

@@ -0,0 +1,66 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class VideoSetting extends BaseModel
{
use HasFactory;
protected $fillable=['link','section_name','status','is_welcome_video'];
public function getVideoById($inputData)
{
return self::where('id',$inputData['section_id'])->first();
}
public function getVideos($inputData = [])
{
$videos = self::query();
if(isset($inputData['is_welcome_video']))
{
$videos->where(['status'=> 1 , 'is_welcome_video'=> $inputData['is_welcome_video']]);
}
return $videos->get();
}
public function deleteVideos($inputData)
{
$video=$this->getVideoById($inputData);
if(!empty($video))
{
return self::where('id', $video->id)->delete();
}
}
public function insertVideo($inputData){
$result = [];
$videoObj =self::whereRaw( 'UPPER(`section_name`) LIKE ?', strtoupper($inputData['section_name']) )->first();
if(empty($videoObj)) {
$result = self::create($inputData);
}
return $result;
}
public function updateVideo($inputData){
$result = [];
$videoObj = $this->getVideoById($inputData);
if(!empty($videoObj)){
$videoObj->link = $inputData['link'];
$videoObj->status = $inputData['status'];
$videoObj->is_welcome_video = $inputData['is_welcome_video'];
$videoObj->save();
$result = $videoObj;
}
return $result;
}
public function getVideoBySectionId($sectionid)
{
$response=[];
$video=self::where('section_id',$sectionid)->first();
if(!empty($video)) {
$response = ['id' => $video->id, 'link' => $video->link, 'section_id' => $video->section_id, 'status' => $video->status];
}
return $response;
}
}

31
app/Models/WaveCycle.php Normal file
View File

@@ -0,0 +1,31 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class WaveCycle extends BaseModel
{
use HasFactory;
protected $fillable = ['user_id','wave_cycle'];
public function insertUserWaveCycle($inputData)
{
$result = [];
$cycleObj = self::where('user_id',$inputData['user_id'])->first();
if(!empty($cycleObj))
{
$inputData['wave_cycle'] = $cycleObj['wave_cycle'] + 1;
$result['data'] = $cycleObj->update($inputData);
}
else{
$inputData['wave_cycle'] = 1;
$result['data'] = self::create($inputData);
}
$result['message'] = 'save successfully';
$result['status'] = true;
return $result;
}
}

View File

@@ -0,0 +1,41 @@
<?php
namespace App\Providers;
use App\Models\VideoSetting;
use creditzombies\LogViewer\Facades\LogViewer;
use Illuminate\Support\ServiceProvider;
use Illuminate\Pagination\Paginator;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
$this->app->singleton('ManageFile', function ($app) {
return new \App\Services\ManageFile();
});
$this->app->singleton('ManageLogging', function ($app) {
return new \App\Services\ManageLogging();
});
LogViewer::auth(function ($request) {
return $request->user()
&& in_array($request->user()->email, config('constant.authorized_log_viewer_emails'));
});
}
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace App\Providers;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Gate;
class AuthServiceProvider extends ServiceProvider
{
/**
* The policy mappings for the application.
*
* @var array
*/
protected $policies = [
// 'App\Model' => 'App\Policies\ModelPolicy',
];
/**
* Register any authentication / authorization services.
*
* @return void
*/
public function boot()
{
$this->registerPolicies();
//
}
}

View File

@@ -0,0 +1,21 @@
<?php
namespace App\Providers;
use Illuminate\Support\Facades\Broadcast;
use Illuminate\Support\ServiceProvider;
class BroadcastServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
Broadcast::routes();
require base_path('routes/channels.php');
}
}

View File

@@ -0,0 +1,32 @@
<?php
namespace App\Providers;
use Illuminate\Auth\Events\Registered;
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Event;
class EventServiceProvider extends ServiceProvider
{
/**
* The event listener mappings for the application.
*
* @var array
*/
protected $listen = [
Registered::class => [
SendEmailVerificationNotification::class,
],
];
/**
* Register any events for your application.
*
* @return void
*/
public function boot()
{
//
}
}

View File

@@ -0,0 +1,52 @@
<?php
namespace App\Providers;
use Illuminate\Cache\RateLimiting\Limit;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Support\Facades\Route;
class RouteServiceProvider extends ServiceProvider
{
/**
* The path to the "home" route for your application.
*
* This is used by Laravel authentication to redirect users after login.
*
* @var string
*/
public const HOME = '/manage-clients';
/**
* Define your route model bindings, pattern filters, etc.
*
* @return void
*/
public function boot()
{
$this->configureRateLimiting();
$this->routes(function () {
Route::middleware('web')
->group(base_path('routes/web.php'));
Route::prefix('api')
->middleware('api')
->group(base_path('routes/api.php'));
});
}
/**
* Configure the rate limiters for the application.
*
* @return void
*/
protected function configureRateLimiting()
{
RateLimiter::for('api', function (Request $request) {
return Limit::perMinute(60);
});
}
}

View File

@@ -0,0 +1,56 @@
<?php
namespace App\Rules;
use Illuminate\Contracts\Validation\Rule;
class PasswordValidationRule implements Rule
{
protected string $password_validation_rule = '/^(?=[-a-zA-Z0-9!@_*.]*$).*/';
protected string $identity_iq_password_validation_rule = '/^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[a-zA-Z]).{8,}$/'; // identity iq
/**
* Create a new rule instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Determine if the validation rule passes.
*
* @param string $attribute
* @param mixed $value
* @return bool
*/
public function passes($attribute, $value)
{
$inputData = request()->all();
$source_type = '';
if(!empty($inputData['creditreport'])){
$source_type = $inputData['creditreport']['credit_report_company_type'];
}if(!empty($inputData['source_type'])){
$source_type = $inputData['source_type'];
}
if($source_type == config('constant.reportType.SMART_CREDIT'))
{
return preg_match($this->password_validation_rule,$value);
}
elseif ($source_type == config('constant.reportType.IDENTITY_IQ')){
return preg_match($this->identity_iq_password_validation_rule,$value);
}
}
/**
* Get the validation error message.
*
* @return string
*/
public function message()
{
return 'Password must be 8 characters and include a capital, lowercase, number and symbol.';
}
}

54
app/Rules/ReCaptcha.php Normal file
View File

@@ -0,0 +1,54 @@
<?php
namespace App\Rules;
use App\Utility\Curl;
use Illuminate\Contracts\Validation\Rule;
class ReCaptcha implements Rule
{
/**
* Create a new rule instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Determine if the validation rule passes.
*
* @param string $attribute
* @param mixed $value
* @return bool
*/
public function passes($attribute, $value)
{
// google captcha url
$url = "https://www.google.com/recaptcha/api/siteverify";
// captcha secret key and value from the UI
$data = [
'secret' => config('app.GOOGLE_RECAPTCHA_SECRET'),
'response' => $value
];
$response = (new Curl($url))->get($data);
return $response['success'];
}
/**
* Get the validation error message.
*
* @return string
*/
public function message()
{
return 'The validation error message.';
}
}

View File

@@ -0,0 +1,50 @@
<?php
namespace App\Rules;
use App\Models\VideoSetting;
use Illuminate\Contracts\Validation\Rule;
class TraningVideoValidationRule implements Rule
{
/**
* Create a new rule instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Determine if the validation rule passes.
*
* @param string $attribute
* @param mixed $value
* @return bool
*/
public function passes($attribute, $value)
{
$inputData = request()->all();
if(isset($inputData['welcome_video_create']) && $inputData['welcome_video_create']) {
$inputData['is_welcome_video'] = true;
$videos=(new VideoSetting())->getVideos($inputData);
if($videos->isEmpty()){
return true;
}
}
}
/**
* Get the validation error message.
*
* @return string
*/
public function message()
{
return 'Already set welcome video.';
}
}

View File

@@ -0,0 +1,101 @@
<?php
namespace App\Services;
use App\Models\Permission;
use App\Models\User;
class ClientService
{
public function getUsers($inputData)
{
return (new User())->getClients($inputData);
}
public function getUserInfoById($id)
{
$result = ['status'=>false,'data'=>[]];
if ($user = User::where(['id'=>$id])->first()) {
$result = ['status'=>true,'data'=>$user];
}
return $result;
}
public function updateUserInfoById($inputData)
{
$result = null;
if ($user = User::where('id',$inputData['id'])->first()) {
$currentWave = $user['wave'];
$maxWave=config('constant.MAX_WAVE');
$currentWave = ($currentWave<$maxWave)? ($currentWave+1) : $maxWave;
$packedData = $this->userDataPacking($inputData);
if(!empty($inputData['reset_account'])){
$packedData['subscription_status'] = 1;
$packedData['wave'] = $currentWave;
$packedData['last_payment_date'] = addDays($inputData['reset_account'],$user->last_payment_date);
}
$user->update($packedData);
$result = $user;
}
return $result;
}
private function userDataPacking($inputData)
{
$outputData=[];
$outputData['first_name'] = $inputData['first_name'];
$outputData['last_name'] = $inputData['last_name'];
$outputData['state'] = $inputData['state'];
$outputData['phone'] = $inputData['phone'];
$outputData['password'] = customEncrypt($inputData['password']);
$outputData['street_no'] = $inputData['street_no'];
$outputData['street_name'] = $inputData['street_name'];
$outputData['city'] = $inputData['city'];
$outputData['zip_code'] = $inputData['zip_code'];
$outputData['credit_report_company_type'] = $inputData['credit_report_company_type'];
$status = $inputData['status'];
if(!empty($inputData['email']))
{
$outputData['email'] = $inputData['email'];
}
if($inputData['status'] == 3)
{
$status = 1;
$outputData['subscription_status'] = 2;
$outputData['account_cancel_datetime'] = getCurrentDate();
}
if(!empty($inputData['user_access_date']))
{
$outputData['user_access_end_date'] = $inputData['user_access_date'];
}
if(!empty($inputData['birth_date']))
{
$outputData['birth_date'] = $inputData['birth_date'];
}
if(!empty($inputData['ssn']))
{
$outputData['ssn'] = $inputData['ssn'];
}
if(!empty($inputData['last_payment_date']))
{
$outputData['last_payment_date'] = $inputData['last_payment_date'];
}
if(!empty($inputData['subscription_status']))
{
$outputData['subscription_status'] = $inputData['subscription_status'];
}
if(!empty($inputData['wave'])){
$outputData['wave'] = $inputData['wave'];
}
if(!empty($inputData['last_import_date'])){
$outputData['last_import_date'] = $inputData['last_import_date'];
}
$outputData['status'] = $status;
return $outputData;
}
}

Some files were not shown because too many files have changed in this diff Show More