Files
wticreatorstudio/app/Helpers/Common.php
Fritz Ramirez 10d0c477c8 Initial commit
2024-02-12 22:54:20 -05:00

996 lines
32 KiB
PHP

<?php
use App\Models\OrderProductDetail;
use Carbon\Carbon;
use Illuminate\Support\Facades\Cache;
use Modules\GeneralSetting\Entities\BusinessSetting;
use Modules\GeneralSetting\Entities\GeneralSetting;
use Modules\Otp\Entities\OtpConfiguration;
use Modules\Seller\Entities\SellerProduct;
if (! function_exists('showStatus')) {
function showStatus($status)
{
if($status == 1){
return 'Active';
}
return 'Inactive';
}
}
if (! function_exists('permissionCheck')) {
function permissionCheck($route_name)
{
if(auth()->check()){
if(auth()->user()->role->type == "superadmin"){
return TRUE;
}elseif (auth()->user()->role->type == "custom") {
if(auth()->user()->permissions->contains('route',$route_name)){
return TRUE;
}else{
return FALSE;
}
}else{
$roles = app('permission_list');
$role = $roles->where('id',auth()->user()->role_id)->first();
if($role != null && $role->permissions->contains('route',$route_name)){
if($role->name != 'Sub Seller'){
return TRUE;
}else{
if(auth()->user()->permissions->contains('route',$route_name)){
return TRUE;
}else{
return FALSE;
}
}
}else{
return FALSE;
}
}
}
return FALSE ;
}
}
if (! function_exists('single_price')) {
function single_price($price)
{
if(app('user_currency') != null){
if (app('user_currency')->symbol == "") {
$formet =',';
$spaceorcomma = ' ';
}else{
$formet = '.';
$spaceorcomma = ',';
}
$price_formet = getNumberTranslate(number_format(($price * app('user_currency')->convert_rate), app('general_setting')->decimal_limit, $formet, $spaceorcomma));
if(app('general_setting')->currency_symbol_position == 'left'){
return app('user_currency')->symbol . $price_formet;
}
elseif(app('general_setting')->currency_symbol_position == 'left_with_space'){
return app('user_currency')->symbol ." ". $price_formet;
}
elseif(app('general_setting')->currency_symbol_position == 'right'){
return $price_formet.app('user_currency')->symbol;
}
elseif(app('general_setting')->currency_symbol_position == 'right_with_space'){
return $price_formet. " " . app('user_currency')->symbol;
} else{
return app('user_currency')->symbol ." ". $price_formet;
}
}
if(app('general_setting')->currency_symbol != null){
if (app('general_setting')->currency_symbol == "") {
$formet =',';
$spaceorcomma = ' ';
}else{
$formet = '.';
$spaceorcomma = ',';
}
$price_formet = getNumberTranslate(number_format($price, app('general_setting')->decimal_limit, $formet, $spaceorcomma));
if(app('general_setting')->currency_symbol_position == 'left'){
return app('general_setting')->currency_symbol . $price_formet;
}
elseif(app('general_setting')->currency_symbol_position == 'left_with_space'){
return app('general_setting')->currency_symbol ." ". $price_formet;
}
elseif(app('general_setting')->currency_symbol_position == 'right'){
return $price_formet . app('general_setting')->currency_symbol;
}
elseif(app('general_setting')->currency_symbol_position == 'right_with_space'){
return $price_formet ." ".app('general_setting')->currency_symbol;
}else{
return app('general_setting')->currency_symbol ." ". $price_formet;
}
}else {
return '$ '.getNumberTranslate(number_format($price, 2));
}
}
}
if (! function_exists('step_decimal')) {
function step_decimal(){
$step_value = app('general_setting')->decimal_limit;
if($step_value > 1){
$process_value = '0.';
for($i=1;$i<=$step_value;$i++){
$process_value .= '0';
}
return doubleval($process_value.'1');
}
return 0;
}
}
//returns combinations of customer choice options array
if (! function_exists('combinations')) {
function combinations($arrays) {
$result = array(array());
foreach ($arrays as $property => $property_values) {
$tmp = array();
foreach ($result as $result_item) {
foreach ($property_values as $property_value) {
$tmp[] = array_merge($result_item, array($property => $property_value));
}
}
$result = $tmp;
}
return $result;
}
}
if(!function_exists('product_attribute_editable')){
function product_attribute_editable($product_id){
$seller_product_exsist = SellerProduct::whereHas('product', function($query) use ($product_id){
return $query->where('product_id', $product_id)->where('user_id','!=',1);
})->pluck('id');
$order_exsist = OrderProductDetail::where('type', 'product')->whereHas('seller_product_sku', function($query) use($product_id){
return $query->whereHas('product', function($q) use($product_id){
return $q->whereHas('product', function($q1) use($product_id){
return $q1->where('product_id', $product_id);
});
});
})->pluck('id');
if($seller_product_exsist->count() || $order_exsist->count()){
return false;
}
return true;
}
}
if (!function_exists('dateConvert')) {
function dateConvert($input_date){
try {
$system_date_format = session()->get('system_date_format');
if (empty($system_date_format)) {
$system_date_format = app('general_setting')->dateFormat->format;
session()->put('system_date_format', $system_date_format);
return date_format(date_create($input_date), $system_date_format);
} else {
return date_format(date_create($input_date), $system_date_format);
}
} catch (\Throwable $th) {
return $input_date;
}
}
}
if (! function_exists('gateway_name')) {
function gateway_name($number) {
if ($number == 1) {
return "Cash On Delivery";
}elseif ($number == 2) {
return "Wallet";
}elseif ($number == 3) {
return "Paypal";
}elseif ($number == 4) {
return "Stripe";
}elseif ($number == 5) {
return "PayStack";
}elseif ($number == 6) {
return "RazorPay";
}elseif ($number == 7) {
return "Bank";
}elseif ($number == 8) {
return "Instamojo";
}elseif ($number == 9) {
return "PayTm";
}else {
return "No Gateway";
}
}
}
if (! function_exists('wallet_balance')) {
function wallet_balance(){
$deposite = auth()->user()->wallet_balances->where('type', 'Deposite')->sum('amount');
$refund_back = auth()->user()->wallet_balances->where('type', 'Refund Back')->sum('amount');
$expensed = auth()->user()->wallet_balances->where('type', 'Cart Payment')->sum('amount');
$rest_money = $deposite + $refund_back - $expensed;
return $rest_money;
}
}
if (! function_exists('seller_wallet_balance_pending')) {
function seller_wallet_balance_pending(){
$deposite = auth()->user()->wallet_balances->where('type', 'Deposite')->where('status', 0)->sum('amount');
$withdraw = auth()->user()->wallet_balances->where('type', 'Withdraw')->where('status', 0)->sum('amount');
$expense = auth()->user()->wallet_balances->where('type', 'Refund')->where('status', 0)->sum('amount');
$income = auth()->user()->wallet_balances->where('type', 'Sale Payment')->where('status', 0)->sum('amount');
$rest_money = $deposite + $income - $expense - $withdraw;
return $rest_money;
}
}
if (! function_exists('seller_wallet_balance_running')) {
function seller_wallet_balance_running(){
$deposite = auth()->user()->wallet_balances->where('type', 'Deposite')->where('status', 1)->sum('amount');
$withdraw = auth()->user()->wallet_balances->where('type', 'Withdraw')->where('status', 1)->sum('amount');
$expense = auth()->user()->wallet_balances->where('type', 'Refund')->where('status', 1)->sum('amount');
$income = auth()->user()->wallet_balances->where('type', 'Sale Payment')->where('status', 1)->sum('amount');
$expensed = auth()->user()->wallet_balances->where('status',1)->where('type', 'Cart Payment')->sum('amount');
$rest_money = $deposite + $income - $expense - $withdraw -$expensed;
return $rest_money;
}
}
if (!function_exists('filterDateFormatingForSearchQuery')) {
function filterDateFormatingForSearchQuery($value)
{
$data = explode("-",$foo = preg_replace('/\s+/', ' ', $value));
return [Carbon::parse($data[0])->format('Y-m-d'),Carbon::parse($data[1])->format('Y-m-d')];
}
}
if (!function_exists('barcodeList')) {
function barcodeList()
{
return $array = array("C39", "C39+", "C39E", "C39E+", "C93", "I25", "POSTNET", "EAN2", "EAN5", "PHARMA2T");
}
}
if (!function_exists('auto_approve_seller')) {
function auto_approve_seller()
{
$autoApproveSetting = GeneralSetting::first();
return $autoApproveSetting->auto_approve_seller;
}
}
if (!function_exists('auto_approve_seller_review')) {
function auto_approve_seller_review()
{
$autoApproveSetting = GeneralSetting::first();
return $autoApproveSetting->auto_approve_seller_review;
}
}
if (!function_exists('auto_approve_product_review')) {
function auto_approve_product_review()
{
$autoApproveSetting = GeneralSetting::first();
return $autoApproveSetting->auto_approve_product_review;
}
}
if (!function_exists('otp_configuration')) {
function otp_configuration($key)
{
if(isModuleActive('Otp')){
$otpConfiguration = OtpConfiguration::where('key',$key)->first();
return $otpConfiguration->value ?? NULL;
}
return NULL;
}
}
if (!function_exists('smsGatewaySetting')) {
function smsGatewaySetting()
{
try {
if (Cache::has('sms_gateway_setting')) {
$sms_gate_way = Cache::get('sms_gateway_setting');
return $sms_gate_way;
} else {
$setting = \Modules\GeneralSetting\Entities\SmsGatewaySetting::first();
if($setting){
$data = collect($setting->toArray())->except(['id','created_at','updated_at'])->all();
Cache::forget('sms_gateway_setting');
Cache::rememberForever('sms_gateway_setting', function () use($data) {
return $data;
});
$sms_gate_way = Cache::get('sms_gateway_setting');
return $sms_gate_way;
}
return false;
}
} catch (Exception $exception) {
return false;
}
}
}
if (!function_exists('validationMessage')) {
function validationMessage($validation_rules)
{
$message = [];
foreach ($validation_rules as $attribute => $rules) {
if (is_array($rules)) {
$single_rule = $rules;
} else {
$single_rule = explode('|', $rules);
}
foreach ($single_rule as $rule) {
$string = explode(':', $rule);
$message [$attribute . '.' . $string[0]] = __('validation.' . $attribute . '.' . $string[0]);
}
}
return $message;
}
}
if (!function_exists('showDate')) {
function showDate($date)
{
try {
if (!$date) {
return '';
}
return date(app('general_setting')->dateFormat->format, strtotime($date));
} catch (\Exception $e) {
return '';
}
}
}
if (!function_exists('showImage')) {
function showImage($path)
{
if($path){
if(strpos($path, 'amazonaws.com') != false || strpos($path, 'digitaloceanspaces.com') != false || strpos($path, 'drive.google.com') != false || strpos($path, 'wasabisys.com') != false || strpos($path, 'backblazeb2.com') != false || strpos($path, 'dropboxusercontent.com') != false || strpos($path, 'b-cdn.net') != false || strpos($path, 'contabostorage.com') != false){
return $path;
}
else{
return asset(asset_path($path));
}
}else{
return asset(asset_path(themeDefaultImg()));
}
}
}
if (!function_exists('activeFileStorage')) {
function activeFileStorage()
{
try {
if (Cache::has('file_storage')) {
$file_storage = Cache::get('file_storage');
return $file_storage;
} else {
$row = BusinessSetting::where('category_type','file_storage')->where('status',1)->first();
if($row){
Cache::forget('file_storage');
Cache::rememberForever('file_storage', function () use($row) {
return $row->type;
});
$file_storage = Cache::get('file_storage');
return $file_storage;
}else{
return 'Local';
}
}
} catch (Exception $exception) {
return false;
}
}
}
if (!function_exists('putEnvConfigration')) {
function putEnvConfigration($envKey, $envValue)
{
$value = '"' . $envValue . '"';
$envFile = app()->environmentFilePath();
$str = file_get_contents($envFile);
$str .= "\n";
$keyPosition = strpos($str, "{$envKey}=");
if (is_bool($keyPosition)) {
$str .= $envKey . '="' . $envValue . '"';
} else {
$endOfLinePosition = strpos($str, "\n", $keyPosition);
$oldLine = substr($str, $keyPosition, $endOfLinePosition - $keyPosition);
$str = str_replace($oldLine, "{$envKey}={$value}", $str);
$str = substr($str, 0, -1);
}
if (!file_put_contents($envFile, $str)) {
return false;
} else {
return true;
}
}
}
if (!function_exists('currencyCode')) {
function currencyCode()
{
$currency_code = app('general_setting')->currency_code;
if(\Session::has('currency')){
$currency = \Modules\GeneralSetting\Entities\Currency::where('id', session()->get('currency'))->first();
$currency_code = $currency->code;
}
if(auth()->check()){
$currency_code = auth()->user()->currency_code;
}
return $currency_code;
}
}
define( 'MINUTE_IN_SECONDS', 60 );
define( 'HOUR_IN_SECONDS', 60 * MINUTE_IN_SECONDS );
define( 'DAY_IN_SECONDS', 24 * HOUR_IN_SECONDS );
define( 'WEEK_IN_SECONDS', 7 * DAY_IN_SECONDS );
define( 'MONTH_IN_SECONDS', 30 * DAY_IN_SECONDS );
define( 'YEAR_IN_SECONDS', 365 * DAY_IN_SECONDS );
function setting_item($item,$default = '',$isArray = false){
$res = \Modules\JobPortal\Entities\Settings::item($item,$default);
if($isArray and !is_array($res)){
$res = (array) json_decode($res,true);
}
return $res;
}
function setting_item_array($item,$default = ''){
return setting_item($item,$default,true);
}
function setting_item_with_lang($item,$locale = '',$default = '',$withOrigin = true){
if(empty($locale)) $locale = app()->getLocale();
if($withOrigin == false and $locale == setting_item('site_locale')){
return $default;
}
if( empty(setting_item('site_locale'))
OR empty(setting_item('site_enable_multi_lang'))
OR $locale == setting_item('site_locale')
){
$locale = '';
}
return \Modules\JobPortal\Entities\Settings::item($item.($locale ? '_'.$locale : ''),$withOrigin ? setting_item($item,$default) : $default);
}
function setting_item_with_lang_raw($item,$locale = '',$default = ''){
return setting_item_with_lang($item,$locale,$default,false);
}
function setting_update_item($item,$val){
$s = \Modules\JobPortal\Entities\Settings::where('name',$item)->first();
if(empty($s)){
$s = new \Modules\JobPortal\Entities\Settings();
$s->name = $item;
}
if(is_array($val) or is_object($val)) $val = json_encode($val);
$s->val = $val;
$s->save();
Cache::forget('setting_' . $item);
return $s;
}
function is_default_lang($lang = '')
{
if(!$lang) $lang = request()->query('lang');
if(!$lang) $lang = request()->route('lang');
if(empty($lang) or $lang == setting_item('site_locale')) return true;
return false;
}
function app_get_locale($locale = false , $before = false , $after = false){
if(setting_item('site_enable_multi_lang') and app()->getLocale() != setting_item('site_locale')){
return $locale ? $before.$locale.$after : $before.app()->getLocale().$after;
}
return '';
}
function home_url(){
return url(app_get_locale(false,'/'));
}
function is_admin(){
if(!auth()->check()) return false;
return permissionCheck('setting_manage');
}
function is_candidate(){
if(!auth()->check()) return false;
return permissionCheck('candidate_manage');
}
function is_employer(){
if(!auth()->check()) return false;
return permissionCheck('employer_manage');
}
function getDatefomat($value) {
return \Carbon\Carbon::parse($value)->format('j F, Y');
}
function get_file_url($file_id,$size="thumb",$resize = true){
if(empty($file_id)) return null;
return \Modules\JobPortalMedia\Helpers\FileHelper::url($file_id,$size,$resize);
}
function get_image_tag($image_id,$size = 'thumb',$options = []){
$options = array_merge($options,[
'lazy'=>true
]);
$url = get_file_url($image_id,$size);
if($url){
$alt = $options['alt'] ?? '';
$attr = '';
$class= $options['class'] ?? '';
if(!empty($options['lazy'])){
$class.=' lazy';
$attr.=" data-src=".e($url)." ";
}else{
$attr.=" src='".e($url)."' ";
}
return sprintf("<img class='%s' %s alt='%s'>",e($class),e($attr),e($alt));
}
}
function get_date_format(){
return setting_item('date_format','m/d/Y');
}
function get_moment_date_format(){
return php_to_moment_format(get_date_format());
}
function php_to_moment_format($format){
$replacements = [
'd' => 'DD',
'D' => 'ddd',
'j' => 'D',
'l' => 'dddd',
'N' => 'E',
'S' => 'o',
'w' => 'e',
'z' => 'DDD',
'W' => 'W',
'F' => 'MMMM',
'm' => 'MM',
'M' => 'MMM',
'n' => 'M',
't' => '', // no equivalent
'L' => '', // no equivalent
'o' => 'YYYY',
'Y' => 'YYYY',
'y' => 'YY',
'a' => 'a',
'A' => 'A',
'B' => '', // no equivalent
'g' => 'h',
'G' => 'H',
'h' => 'hh',
'H' => 'HH',
'i' => 'mm',
's' => 'ss',
'u' => 'SSS',
'e' => 'zz', // deprecated since version 1.6.0 of moment.js
'I' => '', // no equivalent
'O' => '', // no equivalent
'P' => '', // no equivalent
'T' => '', // no equivalent
'Z' => '', // no equivalent
'c' => '', // no equivalent
'r' => '', // no equivalent
'U' => 'X',
];
$momentFormat = strtr($format, $replacements);
return $momentFormat;
}
function display_date($time){
if($time){
if(is_string($time)){
$time = strtotime($time);
}
if(is_object($time)){
return $time->format(get_date_format());
}
}else{
$time=strtotime(today());
}
return date(get_date_format(),$time);
}
function display_datetime($time){
if(is_string($time)){
$time = strtotime($time);
}
if(is_object($time)){
return $time->format(get_date_format().' H:i');
}
return date(get_date_format().' H:i',$time);
}
function human_time_diff($from,$to = false){
if(is_string($from)) $from = strtotime($from);
if(is_string($to)) $to = strtotime($to);
if ( empty( $to ) ) {
$to = time();
}
$diff = (int) abs( $to - $from );
if ( $diff < HOUR_IN_SECONDS ) {
$mins = round( $diff / MINUTE_IN_SECONDS );
if ( $mins <= 1 ) {
$mins = 1;
}
/* translators: Time difference between two dates, in minutes (min=minute). %s: Number of minutes */
if($mins){
$since =__(':num mins',['num'=>$mins]);
}else{
$since =__(':num min',['num'=>$mins]);
}
} elseif ( $diff < DAY_IN_SECONDS && $diff >= HOUR_IN_SECONDS ) {
$hours = round( $diff / HOUR_IN_SECONDS );
if ( $hours <= 1 ) {
$hours = 1;
}
/* translators: Time difference between two dates, in hours. %s: Number of hours */
if($hours){
$since =__(':num hours',['num'=>$hours]);
}else{
$since =__(':num hour',['num'=>$hours]);
}
} elseif ( $diff < WEEK_IN_SECONDS && $diff >= DAY_IN_SECONDS ) {
$days = round( $diff / DAY_IN_SECONDS );
if ( $days <= 1 ) {
$days = 1;
}
/* translators: Time difference between two dates, in days. %s: Number of days */
if($days){
$since =__(':num days',['num'=>$days]);
}else{
$since =__(':num day',['num'=>$days]);
}
} elseif ( $diff < MONTH_IN_SECONDS && $diff >= WEEK_IN_SECONDS ) {
$weeks = round( $diff / WEEK_IN_SECONDS );
if ( $weeks <= 1 ) {
$weeks = 1;
}
/* translators: Time difference between two dates, in weeks. %s: Number of weeks */
if($weeks){
$since =__(':num weeks',['num'=>$weeks]);
}else{
$since =__(':num week',['num'=>$weeks]);
}
} elseif ( $diff < YEAR_IN_SECONDS && $diff >= MONTH_IN_SECONDS ) {
$months = round( $diff / MONTH_IN_SECONDS );
if ( $months <= 1 ) {
$months = 1;
}
/* translators: Time difference between two dates, in months. %s: Number of months */
if($months){
$since =__(':num months',['num'=>$months]);
}else{
$since =__(':num month',['num'=>$months]);
}
} elseif ( $diff >= YEAR_IN_SECONDS ) {
$years = round( $diff / YEAR_IN_SECONDS );
if ( $years <= 1 ) {
$years = 1;
}
/* translators: Time difference between two dates, in years. %s: Number of years */
if($years){
$since =__(':num years',['num'=>$years]);
}else{
$since =__(':num year',['num'=>$years]);
}
}
return $since;
}
function human_time_diff_short($from,$to = false){
if(!$to) $to = time();
$today = strtotime(date('Y-m-d 00:00:00',$to));
$diff = $from - $to;
if($from > $today){
return date('h:i A',$from);
}
if($diff < 5* DAY_IN_SECONDS){
return date('D',$from);
}
return date('M d',$from);
}
function _n($l,$m,$count){
if($count){
return $m;
}
return $l;
}
function get_country_lists(){
$countries = array
(
'AF' => 'Afghanistan',
'AX' => 'Aland Islands',
'AL' => 'Albania',
'DZ' => 'Algeria',
'AS' => 'American Samoa',
'AD' => 'Andorra',
'AO' => 'Angola',
'AI' => 'Anguilla',
'AQ' => 'Antarctica',
'AG' => 'Antigua And Barbuda',
'AR' => 'Argentina',
'AM' => 'Armenia',
'AW' => 'Aruba',
'AU' => 'Australia',
'AT' => 'Austria',
'AZ' => 'Azerbaijan',
'BS' => 'Bahamas',
'BH' => 'Bahrain',
'BD' => 'Bangladesh',
'BB' => 'Barbados',
'BY' => 'Belarus',
'BE' => 'Belgium',
'BZ' => 'Belize',
'BJ' => 'Benin',
'BM' => 'Bermuda',
'BT' => 'Bhutan',
'BO' => 'Bolivia',
'BA' => 'Bosnia And Herzegovina',
'BW' => 'Botswana',
'BV' => 'Bouvet Island',
'BR' => 'Brazil',
'IO' => 'British Indian Ocean Territory',
'BN' => 'Brunei Darussalam',
'BG' => 'Bulgaria',
'BF' => 'Burkina Faso',
'BI' => 'Burundi',
'KH' => 'Cambodia',
'CM' => 'Cameroon',
'CA' => 'Canada',
'CV' => 'Cape Verde',
'KY' => 'Cayman Islands',
'CF' => 'Central African Republic',
'TD' => 'Chad',
'CL' => 'Chile',
'CN' => 'China',
'CX' => 'Christmas Island',
'CC' => 'Cocos (Keeling) Islands',
'CO' => 'Colombia',
'KM' => 'Comoros',
'CG' => 'Congo',
'CD' => 'Congo, Democratic Republic',
'CK' => 'Cook Islands',
'CR' => 'Costa Rica',
'CI' => 'Cote D\'Ivoire',
'HR' => 'Croatia',
'CU' => 'Cuba',
'CY' => 'Cyprus',
'CZ' => 'Czech Republic',
'DK' => 'Denmark',
'DJ' => 'Djibouti',
'DM' => 'Dominica',
'DO' => 'Dominican Republic',
'EC' => 'Ecuador',
'EG' => 'Egypt',
'SV' => 'El Salvador',
'GQ' => 'Equatorial Guinea',
'ER' => 'Eritrea',
'EE' => 'Estonia',
'ET' => 'Ethiopia',
'FK' => 'Falkland Islands (Malvinas)',
'FO' => 'Faroe Islands',
'FJ' => 'Fiji',
'FI' => 'Finland',
'FR' => 'France',
'GF' => 'French Guiana',
'PF' => 'French Polynesia',
'TF' => 'French Southern Territories',
'GA' => 'Gabon',
'GM' => 'Gambia',
'GE' => 'Georgia',
'DE' => 'Germany',
'GH' => 'Ghana',
'GI' => 'Gibraltar',
'GR' => 'Greece',
'GL' => 'Greenland',
'GD' => 'Grenada',
'GP' => 'Guadeloupe',
'GU' => 'Guam',
'GT' => 'Guatemala',
'GG' => 'Guernsey',
'GN' => 'Guinea',
'GW' => 'Guinea-Bissau',
'GY' => 'Guyana',
'HT' => 'Haiti',
'HM' => 'Heard Island & Mcdonald Islands',
'VA' => 'Holy See (Vatican City State)',
'HN' => 'Honduras',
'HK' => 'Hong Kong',
'HU' => 'Hungary',
'IS' => 'Iceland',
'IN' => 'India',
'ID' => 'Indonesia',
'IR' => 'Iran, Islamic Republic Of',
'IQ' => 'Iraq',
'IE' => 'Ireland',
'IM' => 'Isle Of Man',
'IL' => 'Israel',
'IT' => 'Italy',
'JM' => 'Jamaica',
'JP' => 'Japan',
'JE' => 'Jersey',
'JO' => 'Jordan',
'KZ' => 'Kazakhstan',
'KE' => 'Kenya',
'KI' => 'Kiribati',
'KR' => 'Korea',
'KW' => 'Kuwait',
'KG' => 'Kyrgyzstan',
'LA' => 'Lao People\'s Democratic Republic',
'LV' => 'Latvia',
'LB' => 'Lebanon',
'LS' => 'Lesotho',
'LR' => 'Liberia',
'LY' => 'Libyan Arab Jamahiriya',
'LI' => 'Liechtenstein',
'LT' => 'Lithuania',
'LU' => 'Luxembourg',
'MO' => 'Macao',
'MK' => 'Macedonia',
'MG' => 'Madagascar',
'MW' => 'Malawi',
'MY' => 'Malaysia',
'MV' => 'Maldives',
'ML' => 'Mali',
'MT' => 'Malta',
'MH' => 'Marshall Islands',
'MQ' => 'Martinique',
'MR' => 'Mauritania',
'MU' => 'Mauritius',
'YT' => 'Mayotte',
'MX' => 'Mexico',
'FM' => 'Micronesia, Federated States Of',
'MD' => 'Moldova',
'MC' => 'Monaco',
'MN' => 'Mongolia',
'ME' => 'Montenegro',
'MS' => 'Montserrat',
'MA' => 'Morocco',
'MZ' => 'Mozambique',
'MM' => 'Myanmar',
'NA' => 'Namibia',
'NR' => 'Nauru',
'NP' => 'Nepal',
'NL' => 'Netherlands',
'AN' => 'Netherlands Antilles',
'NC' => 'New Caledonia',
'NZ' => 'New Zealand',
'NI' => 'Nicaragua',
'NE' => 'Niger',
'NG' => 'Nigeria',
'NU' => 'Niue',
'NF' => 'Norfolk Island',
'MP' => 'Northern Mariana Islands',
'NO' => 'Norway',
'OM' => 'Oman',
'PK' => 'Pakistan',
'PW' => 'Palau',
'PS' => 'Palestinian Territory, Occupied',
'PA' => 'Panama',
'PG' => 'Papua New Guinea',
'PY' => 'Paraguay',
'PE' => 'Peru',
'PH' => 'Philippines',
'PN' => 'Pitcairn',
'PL' => 'Poland',
'PT' => 'Portugal',
'PR' => 'Puerto Rico',
'QA' => 'Qatar',
'RE' => 'Reunion',
'RO' => 'Romania',
'RU' => 'Russian Federation',
'RW' => 'Rwanda',
'BL' => 'Saint Barthelemy',
'SH' => 'Saint Helena',
'KN' => 'Saint Kitts And Nevis',
'LC' => 'Saint Lucia',
'MF' => 'Saint Martin',
'PM' => 'Saint Pierre And Miquelon',
'VC' => 'Saint Vincent And Grenadines',
'WS' => 'Samoa',
'SM' => 'San Marino',
'ST' => 'Sao Tome And Principe',
'SA' => 'Saudi Arabia',
'SN' => 'Senegal',
'RS' => 'Serbia',
'SC' => 'Seychelles',
'SL' => 'Sierra Leone',
'SG' => 'Singapore',
'SK' => 'Slovakia',
'SI' => 'Slovenia',
'SB' => 'Solomon Islands',
'SO' => 'Somalia',
'ZA' => 'South Africa',
'GS' => 'South Georgia And Sandwich Isl.',
'ES' => 'Spain',
'LK' => 'Sri Lanka',
'SD' => 'Sudan',
'SR' => 'Suriname',
'SJ' => 'Svalbard And Jan Mayen',
'SZ' => 'Swaziland',
'SE' => 'Sweden',
'CH' => 'Switzerland',
'SY' => 'Syrian Arab Republic',
'TW' => 'Taiwan',
'TJ' => 'Tajikistan',
'TZ' => 'Tanzania',
'TH' => 'Thailand',
'TL' => 'Timor-Leste',
'TG' => 'Togo',
'TK' => 'Tokelau',
'TO' => 'Tonga',
'TT' => 'Trinidad And Tobago',
'TN' => 'Tunisia',
'TR' => 'Turkey',
'TM' => 'Turkmenistan',
'TC' => 'Turks And Caicos Islands',
'TV' => 'Tuvalu',
'UG' => 'Uganda',
'UA' => 'Ukraine',
'AE' => 'United Arab Emirates',
'GB' => 'United Kingdom',
'US' => 'United States',
'UM' => 'United States Outlying Islands',
'UY' => 'Uruguay',
'UZ' => 'Uzbekistan',
'VU' => 'Vanuatu',
'VE' => 'Venezuela',
'VN' => 'Viet Nam',
'VG' => 'Virgin Islands, British',
'VI' => 'Virgin Islands, U.S.',
'WF' => 'Wallis And Futuna',
'EH' => 'Western Sahara',
'YE' => 'Yemen',
'ZM' => 'Zambia',
'ZW' => 'Zimbabwe',
);
return $countries;
}
function get_country_name($name){
$all = get_country_lists();
return $all[$name] ?? $name;
}
function get_user_view($userId){
$clientIp = request()->ip();
$userViews = \Modules\JobPortal\Entities\UserViews::where('user_id',$userId)->where('client_ip',$clientIp)->whereDate('created_at',\Carbon\Carbon::today())->count();
if (!$userViews){
$userViews = new \Modules\JobPortal\Entities\UserViews();
$userViews->user_id = $userId;
$userViews->client_ip = $clientIp;
$userViews->save();
}
}
function recaptcha_field($action){
return \Modules\JobPortal\Helpers\ReCaptchaEngine::captcha($action);
}