Back | Home
الـ Path الحالي: /home/picotech/domains/instantly.picotech.app/public_html/public/uploads/.././js/../../app/Http/.
الملفات الموجودة في هذا الـ Path:
.
..
Controllers
Kernel.php
Middleware
helpers.php
مشاهدة ملف: helpers.php
<?php
use App\Models\Activity;
use Illuminate\Support\Str;
function isSidebarActive($routeName)
{
return request()->routeIs($routeName) ? 'active' : '';
}
function emailTemplate(){
$temp=
[
"0"=>[
'title'=>'Exclusive Offer: 10% Off Your Next Purchase!',
'body'=>'Hello {first_name},<br>
We appreciate your business! Check out our new arrivals and enjoy an exclusive 10% discount on your next purchase. Use code: THANKYOU10.
<br>
Best regards',
],
"1"=>[
'title'=>'Annual Sale Alert: Up to 50% Off Inside!',
'body'=>'Dear {first_name} {last_name},
<br>
Exciting news! Our annual sale is here. Shop now for up to 50% off on your favorite items. Limited stock.Do not miss out!
<br>
Regards',
],
"2"=>[
'title'=>'Flash Sale Alert: Up to 40% Off - Act Fast!',
'body'=>'Hi {first_name},
<br>
Quick update: Our Flash Sale is happening now! Save big with discounts up to 40%. Act fast—ends tomorrow.
<br>
Cheers,',
]
];
return $temp;
}
function isSidebarTrue($routeNames)
{
$istrue = false;
foreach ($routeNames as $routeName){
if (request()->routeIs($routeName)){
$istrue = true;
break;
}
}
return $istrue;
}
function getLastNDays($days, $format = 'Y-m-d')
{
$m = date("m");
$de = date("d");
$y = date("Y");
$dateArray = array();
for ($i = 0; $i <= $days - 1; $i++) {
$dateArray[] = '"' . date($format, mktime(0, 0, 0, $m, ($de - $i), $y)) . '"';
}
return array_reverse($dateArray);
}
function replaceMessageBody($body, $campaign, $message_log ,$template){
$templateData = $template?json_decode($template):[];
$images = route('get.image',['campaign_id'=>$campaign,'message_log'=>$message_log]);
if (isset($templateData->logo_img) && $templateData->logo_img){
$logo = '<div style="background-color: rgb(239, 242, 247); padding-top: 20px; padding-bottom: 20px; width: 570px;">
<img src="'. asset('uploads/'.$templateData->logo_img) .'" alt="" style="width: 200px; height: 90px; display: block; margin-right: auto; margin-left: auto;">
</div>';
}elseif (isset($templateData->logo_url) && $templateData->logo_url){
$logo = '<div style="background-color: rgb(239, 242, 247); padding-top: 20px; padding-bottom: 20px; width: 570px;">
<img src="'. $templateData->logo_url .'" alt="" style="width: 200px; height: 90px; display: block; margin-right: auto; margin-left: auto;">
</div>';
}else{
$logo = '';
}
if (isset($templateData->heading) && $templateData->heading){
$heading= '<div style="margin-top: 50px; margin-bottom: 30px; text-align: center;">
<h1 style="font-weight: bolder;">'.$templateData->heading.'</h1>
</div>';
}else{
$heading = '';
}
if (isset($templateData->product_img_upload) && $templateData->product_img_upload){
$product_img = '<div>
<img src="'. asset('uploads/'.$templateData->product_img_upload) .'" alt="" style=" width: 570px; height: 240px; margin-bottom: 60px;">
</div>';
}elseif (isset($templateData->product_image_url) && $templateData->product_image_url){
$product_img = '<div>
<img src="'. $templateData->product_image_url .'" alt="" style=" width: 570px; height: 240px; margin-bottom: 60px;">
</div>';
}else{
$product_img = '';
}
if (isset($templateData->first_product_img_upload) && $templateData->first_product_img_upload){
$first_product_img = '<div>
<img src="'. asset('uploads/'.$templateData->first_product_img_upload) .'" alt="" style="width: 270px; height: 150px;">
</div>';
}elseif (isset($templateData->first_product_image_url) && $templateData->first_product_image_url){
$first_product_img = '<div>
<img src="'. $templateData->first_product_image_url .'" alt="" style="width: 270px; height: 150px;">
</div>';
}else{
$first_product_img = '';
}
if (isset($templateData->sec_product_img_upload) && $templateData->sec_product_img_upload){
$sec_product_img = '<div>
<img src="'. asset('uploads/'.$templateData->sec_product_img_upload) .'" alt="" style="width: 270px; height: 150px;">
</div>';
}elseif (isset($templateData->sec_product_image_url) && $templateData->sec_product_image_url){
$sec_product_img = '<div>
<img src="'. $templateData->sec_product_image_url .'" alt="" style="width: 270px; height: 150px; margin-left: 30px;">
</div>';
}else{
$sec_product_img = '';
}
if (isset($templateData->campaign_title) && $templateData->campaign_title){
$campaign_title = '<h2 style="font-weight: bolder; margin-top: 50px; margin-bottom: 20px;">'.$templateData->campaign_title.'</h2>';
}else{
$campaign_title = '';
}
if (isset($templateData->campaign_description) && $templateData->campaign_description){
$campaign_description = '<p style="font-size: 1.1rem;">'.$templateData->campaign_description.'</p>';
}else{
$campaign_description = '';
}
if (isset($templateData->campaign_call_to_action) && $templateData->campaign_call_to_action){
$campaign_call_to_action = '<a href="'.$templateData->campaign_call_to_action.'" style=" background: #0092ff; border: 1px solid #0092ff; border-radius: 3px; color: #fff; display: inline-block; outline: 0; font-size: 1rem!important; padding: calc(0.5rem - 1px) calc(0.5rem * 2 - 1px); text-decoration: none;text-align: center; margin-top: 30px; margin-bottom: 30px; display: block; margin-left: auto; margin-right: auto; width: 30%;">Call to action</a>';
}else{
$campaign_call_to_action = '';
}
if (isset($templateData->company_name) && $templateData->company_name){
$company_name = '<h5 style=" font-weight: bold; margin-bottom: 20px; margin-top: 20px;">'.$templateData->company_name.'</h5>';
}else{
$company_name = '';
}
if (isset($templateData->email_description) && $templateData->email_description){
$email_description = '<p>'.$templateData->email_description.'</p>';
}else{
$email_description = '';
}
if (isset($templateData->unsubscribe_link) && $templateData->unsubscribe_link){
$unsubscribe_link = '<a href="'.$templateData->unsubscribe_link.'&track_no=1" style="text-decoration: underline;">Unsubscribe</a>';
}else{
$unsubscribe_link = '';
}
$unsubscribeUrl=isset($campaign)?'<a style="margin-top: 30px !important; text-align: center !important;" href="'.route('unsubscribe',['campaign'=>$campaign,'message'=>$message_log,'track_no'=>'1']).'">Unsubscribe </a>':'';
if ($template){
$htmlBody = '<div style="display: block; margin-left: auto; margin-right: auto; width: 50%;">
<img src="'. $images .'" alt="open" width="1" height="1">
'.$logo.'
'.$heading.'
'.$product_img.'
<div style="display: flex;">
'.$first_product_img.'
'.$sec_product_img.'
</div>
<div>
'.$campaign_title.'
'.$campaign_description.'
'.$campaign_call_to_action.'
</div>
<div style="padding: 20px 0px; vertical-align: top; justify-content: flex-start; width: 600px; background-color: rgb(239, 242, 247); text-align: center;">
'.$company_name.'
'.$email_description.'
'.$unsubscribe_link.'
'.$logo.'
</div>
</div>';
}else{
$htmlBody = '<div class="row">
<div class="col-sm-12">
<img src="'. $images .'" alt="open">
</div>
<div class="col-sm-12">
<div>
<div>
'.$body.'
</div>
'.$unsubscribeUrl.'
</div>
</div>
</div>';
}
$doc = new \DOMDocument();
@$doc->loadHTML($htmlBody);
foreach ($doc->getElementsByTagName('a') as $anchor) {
$link = $anchor->getAttribute('href');
$track_no=Str::contains($link,['track_no']);
if($link){
$routeData=['campaign' => $campaign, 'message' => $message_log, 'redirect' => urlencode($link)];
if($track_no){
$routeData['track_no']='1';
}
$link = route('clicked', $routeData);
$anchor->setAttribute('href', $link);
}
}
return $doc->saveHTML();
}
function get_pages($position)
{
$pages = cache('pages');
if (!$pages) {
$pages = \App\Models\Page::where('status', 'published')->orderBy('created_at', 'desc')->get();
$sortSettings = [];
foreach ($pages as $page) {
$sortSettings[$page->position][] = $page;
}
cache()->remember('pages', 10800, function () use ($sortSettings) {
return $sortSettings;
});
} else {
$sortSettings = $pages;
}
return isset($sortSettings[$position]) ? $sortSettings[$position] : [];
}
function get_settings($name)
{
$value = cache('settings');
if (!$value) {
if (\Schema::hasTable('settings')) {
$settings = \App\Models\Settings::where('admin_id', 1)->get();
$sortSettings = [];
foreach ($settings as $setting) {
$sortSettings[$setting->name] = $setting->value;
}
cache()->remember('settings', 10800, function () use ($sortSettings) {
return $sortSettings;
});
}
} else {
$sortSettings = $value;
}
return isset($sortSettings[$name]) ? $sortSettings[$name] : '';
}
function get_email_template($template)
{
$temp = \App\Models\EmailTemplate::where('type', $template)->first();
if (isset($temp) && $temp->status != 'active') {
return true;
}
return $temp;
}
function getAllTimeZones()
{
$timezone = array();
$timestamp = time();
foreach (timezone_identifiers_list(\DateTimeZone::ALL) as $key => $t) {
date_default_timezone_set($t);
$timezone[$key]['zone'] = $t;
$timezone[$key]['GMT_difference'] = date('P', $timestamp);
}
$timezone = collect($timezone)->sortBy('GMT_difference');
return $timezone;
}
function get_available_languages()
{
$value = cache('language');
if (!$value) {
$all_locales = Translation::select('locale')->groupBy('locale')->get()->pluck('locale')->toArray();
cache()->remember('language', 10800, function () use ($all_locales) {
return $all_locales;
});
return $all_locales;
} else {
return $value;
}
}
function setActivity($customer, $type, $ref, $ref_id, $message)
{
if (!$customer || !$type || !$ref || !$ref_id || !$message) {
return;
}
$activity = new Activity();
$activity->customer_id = $customer;
$activity->type = $type;
$activity->ref = $ref;
$activity->ref_id = $ref_id;
$activity->message = $message;
$activity->save();
}
function formatDate($date)
{
if(!$date) return "";
$setting = json_decode(get_settings('local_setting'));
if (!isset($setting->date_time_format) || !isset($setting->date_time_separator) || !isset($setting->timezone)) return $date;
return str_replace([',', '_'], [', ', ' '], Carbon\Carbon::createFromTimeString($date)->timezone($setting->timezone)->format(str_replace(' ', $setting->date_time_separator, $setting->date_time_format)));
}
function formatNumber($number)
{
$setting = json_decode(get_settings('local_setting'));
if (!isset($setting->decimal_format) || !isset($setting->decimals) || !isset($setting->thousand_separator)) return $number;
try {
return number_format($number, $setting->decimals, $setting->decimal_format, $setting->thousand_separator);
} catch (\Exception $ex) {
return $number;
}
}
function formatNumberWithCurrSymbol($number)
{
$setting = json_decode(get_settings('local_setting'));
$formattedNumber = formatNumber($number);
if (!isset($setting->currency_symbol_position) || !isset($setting->currency_symbol)) return $formattedNumber;
if ($setting->currency_symbol_position == 'after')
return $formattedNumber . $setting->currency_symbol;
else if ($setting->currency_symbol_position == 'before')
return $setting->currency_symbol . $formattedNumber;
else
return $formattedNumber;
}
function get_currency(){
$setting = json_decode(get_settings('local_setting'));
$currencyCode = isset($setting->currency_code)?$setting->currency_code:'USD';
// if (!isset($setting->currency_code)) return 'USD';
return $currencyCode;
}
function getCountryCode()
{
$countryArray = array(
'AD' => array('name' => 'ANDORRA', 'code' => '376'),
'AE' => array('name' => 'UNITED ARAB EMIRATES', 'code' => '971'),
'AF' => array('name' => 'AFGHANISTAN', 'code' => '93'),
'AG' => array('name' => 'ANTIGUA AND BARBUDA', 'code' => '1268'),
'AI' => array('name' => 'ANGUILLA', 'code' => '1264'),
'AL' => array('name' => 'ALBANIA', 'code' => '355'),
'AM' => array('name' => 'ARMENIA', 'code' => '374'),
'AN' => array('name' => 'NETHERLANDS ANTILLES', 'code' => '599'),
'AO' => array('name' => 'ANGOLA', 'code' => '244'),
'AQ' => array('name' => 'ANTARCTICA', 'code' => '672'),
'AR' => array('name' => 'ARGENTINA', 'code' => '54'),
'AS' => array('name' => 'AMERICAN SAMOA', 'code' => '1684'),
'AT' => array('name' => 'AUSTRIA', 'code' => '43'),
'AU' => array('name' => 'AUSTRALIA', 'code' => '61'),
'AW' => array('name' => 'ARUBA', 'code' => '297'),
'AZ' => array('name' => 'AZERBAIJAN', 'code' => '994'),
'BA' => array('name' => 'BOSNIA AND HERZEGOVINA', 'code' => '387'),
'BB' => array('name' => 'BARBADOS', 'code' => '1246'),
'BD' => array('name' => 'BANGLADESH', 'code' => '880'),
'BE' => array('name' => 'BELGIUM', 'code' => '32'),
'BF' => array('name' => 'BURKINA FASO', 'code' => '226'),
'BG' => array('name' => 'BULGARIA', 'code' => '359'),
'BH' => array('name' => 'BAHRAIN', 'code' => '973'),
'BI' => array('name' => 'BURUNDI', 'code' => '257'),
'BJ' => array('name' => 'BENIN', 'code' => '229'),
'BL' => array('name' => 'SAINT BARTHELEMY', 'code' => '590'),
'BM' => array('name' => 'BERMUDA', 'code' => '1441'),
'BN' => array('name' => 'BRUNEI DARUSSALAM', 'code' => '673'),
'BO' => array('name' => 'BOLIVIA', 'code' => '591'),
'BR' => array('name' => 'BRAZIL', 'code' => '55'),
'BS' => array('name' => 'BAHAMAS', 'code' => '1242'),
'BT' => array('name' => 'BHUTAN', 'code' => '975'),
'BW' => array('name' => 'BOTSWANA', 'code' => '267'),
'BY' => array('name' => 'BELARUS', 'code' => '375'),
'BZ' => array('name' => 'BELIZE', 'code' => '501'),
'CA' => array('name' => 'CANADA', 'code' => '1'),
'CC' => array('name' => 'COCOS (KEELING) ISLANDS', 'code' => '61'),
'CD' => array('name' => 'CONGO, THE DEMOCRATIC REPUBLIC OF THE', 'code' => '243'),
'CF' => array('name' => 'CENTRAL AFRICAN REPUBLIC', 'code' => '236'),
'CG' => array('name' => 'CONGO', 'code' => '242'),
'CH' => array('name' => 'SWITZERLAND', 'code' => '41'),
'CI' => array('name' => 'COTE D IVOIRE', 'code' => '225'),
'CK' => array('name' => 'COOK ISLANDS', 'code' => '682'),
'CL' => array('name' => 'CHILE', 'code' => '56'),
'CM' => array('name' => 'CAMEROON', 'code' => '237'),
'CN' => array('name' => 'CHINA', 'code' => '86'),
'CO' => array('name' => 'COLOMBIA', 'code' => '57'),
'CR' => array('name' => 'COSTA RICA', 'code' => '506'),
'CU' => array('name' => 'CUBA', 'code' => '53'),
'CV' => array('name' => 'CAPE VERDE', 'code' => '238'),
'CX' => array('name' => 'CHRISTMAS ISLAND', 'code' => '61'),
'CY' => array('name' => 'CYPRUS', 'code' => '357'),
'CZ' => array('name' => 'CZECH REPUBLIC', 'code' => '420'),
'DE' => array('name' => 'GERMANY', 'code' => '49'),
'DJ' => array('name' => 'DJIBOUTI', 'code' => '253'),
'DK' => array('name' => 'DENMARK', 'code' => '45'),
'DM' => array('name' => 'DOMINICA', 'code' => '1767'),
'DO' => array('name' => 'DOMINICAN REPUBLIC', 'code' => '1809'),
'DZ' => array('name' => 'ALGERIA', 'code' => '213'),
'EC' => array('name' => 'ECUADOR', 'code' => '593'),
'EE' => array('name' => 'ESTONIA', 'code' => '372'),
'EG' => array('name' => 'EGYPT', 'code' => '20'),
'ER' => array('name' => 'ERITREA', 'code' => '291'),
'ES' => array('name' => 'SPAIN', 'code' => '34'),
'ET' => array('name' => 'ETHIOPIA', 'code' => '251'),
'FI' => array('name' => 'FINLAND', 'code' => '358'),
'FJ' => array('name' => 'FIJI', 'code' => '679'),
'FK' => array('name' => 'FALKLAND ISLANDS (MALVINAS)', 'code' => '500'),
'FM' => array('name' => 'MICRONESIA, FEDERATED STATES OF', 'code' => '691'),
'FO' => array('name' => 'FAROE ISLANDS', 'code' => '298'),
'FR' => array('name' => 'FRANCE', 'code' => '33'),
'GA' => array('name' => 'GABON', 'code' => '241'),
'GB' => array('name' => 'UNITED KINGDOM', 'code' => '44'),
'GD' => array('name' => 'GRENADA', 'code' => '1473'),
'GE' => array('name' => 'GEORGIA', 'code' => '995'),
'GH' => array('name' => 'GHANA', 'code' => '233'),
'GI' => array('name' => 'GIBRALTAR', 'code' => '350'),
'GL' => array('name' => 'GREENLAND', 'code' => '299'),
'GM' => array('name' => 'GAMBIA', 'code' => '220'),
'GN' => array('name' => 'GUINEA', 'code' => '224'),
'GQ' => array('name' => 'EQUATORIAL GUINEA', 'code' => '240'),
'GR' => array('name' => 'GREECE', 'code' => '30'),
'GT' => array('name' => 'GUATEMALA', 'code' => '502'),
'GU' => array('name' => 'GUAM', 'code' => '1671'),
'GW' => array('name' => 'GUINEA-BISSAU', 'code' => '245'),
'GY' => array('name' => 'GUYANA', 'code' => '592'),
'HK' => array('name' => 'HONG KONG', 'code' => '852'),
'HN' => array('name' => 'HONDURAS', 'code' => '504'),
'HR' => array('name' => 'CROATIA', 'code' => '385'),
'HT' => array('name' => 'HAITI', 'code' => '509'),
'HU' => array('name' => 'HUNGARY', 'code' => '36'),
'ID' => array('name' => 'INDONESIA', 'code' => '62'),
'IE' => array('name' => 'IRELAND', 'code' => '353'),
'IL' => array('name' => 'ISRAEL', 'code' => '972'),
'IM' => array('name' => 'ISLE OF MAN', 'code' => '44'),
'IN' => array('name' => 'INDIA', 'code' => '91'),
'IQ' => array('name' => 'IRAQ', 'code' => '964'),
'IR' => array('name' => 'IRAN, ISLAMIC REPUBLIC OF', 'code' => '98'),
'IS' => array('name' => 'ICELAND', 'code' => '354'),
'IT' => array('name' => 'ITALY', 'code' => '39'),
'JM' => array('name' => 'JAMAICA', 'code' => '1876'),
'JO' => array('name' => 'JORDAN', 'code' => '962'),
'JP' => array('name' => 'JAPAN', 'code' => '81'),
'KE' => array('name' => 'KENYA', 'code' => '254'),
'KG' => array('name' => 'KYRGYZSTAN', 'code' => '996'),
'KH' => array('name' => 'CAMBODIA', 'code' => '855'),
'KI' => array('name' => 'KIRIBATI', 'code' => '686'),
'KM' => array('name' => 'COMOROS', 'code' => '269'),
'KN' => array('name' => 'SAINT KITTS AND NEVIS', 'code' => '1869'),
'KP' => array('name' => 'KOREA DEMOCRATIC PEOPLES REPUBLIC OF', 'code' => '850'),
'KR' => array('name' => 'KOREA REPUBLIC OF', 'code' => '82'),
'KW' => array('name' => 'KUWAIT', 'code' => '965'),
'KY' => array('name' => 'CAYMAN ISLANDS', 'code' => '1345'),
'KZ' => array('name' => 'KAZAKSTAN', 'code' => '7'),
'LA' => array('name' => 'LAO PEOPLES DEMOCRATIC REPUBLIC', 'code' => '856'),
'LB' => array('name' => 'LEBANON', 'code' => '961'),
'LC' => array('name' => 'SAINT LUCIA', 'code' => '1758'),
'LI' => array('name' => 'LIECHTENSTEIN', 'code' => '423'),
'LK' => array('name' => 'SRI LANKA', 'code' => '94'),
'LR' => array('name' => 'LIBERIA', 'code' => '231'),
'LS' => array('name' => 'LESOTHO', 'code' => '266'),
'LT' => array('name' => 'LITHUANIA', 'code' => '370'),
'LU' => array('name' => 'LUXEMBOURG', 'code' => '352'),
'LV' => array('name' => 'LATVIA', 'code' => '371'),
'LY' => array('name' => 'LIBYAN ARAB JAMAHIRIYA', 'code' => '218'),
'MA' => array('name' => 'MOROCCO', 'code' => '212'),
'MC' => array('name' => 'MONACO', 'code' => '377'),
'MD' => array('name' => 'MOLDOVA, REPUBLIC OF', 'code' => '373'),
'ME' => array('name' => 'MONTENEGRO', 'code' => '382'),
'MF' => array('name' => 'SAINT MARTIN', 'code' => '1599'),
'MG' => array('name' => 'MADAGASCAR', 'code' => '261'),
'MH' => array('name' => 'MARSHALL ISLANDS', 'code' => '692'),
'MK' => array('name' => 'MACEDONIA, THE FORMER YUGOSLAV REPUBLIC OF', 'code' => '389'),
'ML' => array('name' => 'MALI', 'code' => '223'),
'MM' => array('name' => 'MYANMAR', 'code' => '95'),
'MN' => array('name' => 'MONGOLIA', 'code' => '976'),
'MO' => array('name' => 'MACAU', 'code' => '853'),
'MP' => array('name' => 'NORTHERN MARIANA ISLANDS', 'code' => '1670'),
'MR' => array('name' => 'MAURITANIA', 'code' => '222'),
'MS' => array('name' => 'MONTSERRAT', 'code' => '1664'),
'MT' => array('name' => 'MALTA', 'code' => '356'),
'MU' => array('name' => 'MAURITIUS', 'code' => '230'),
'MV' => array('name' => 'MALDIVES', 'code' => '960'),
'MW' => array('name' => 'MALAWI', 'code' => '265'),
'MX' => array('name' => 'MEXICO', 'code' => '52'),
'MY' => array('name' => 'MALAYSIA', 'code' => '60'),
'MZ' => array('name' => 'MOZAMBIQUE', 'code' => '258'),
'NA' => array('name' => 'NAMIBIA', 'code' => '264'),
'NC' => array('name' => 'NEW CALEDONIA', 'code' => '687'),
'NE' => array('name' => 'NIGER', 'code' => '227'),
'NG' => array('name' => 'NIGERIA', 'code' => '234'),
'NI' => array('name' => 'NICARAGUA', 'code' => '505'),
'NL' => array('name' => 'NETHERLANDS', 'code' => '31'),
'NO' => array('name' => 'NORWAY', 'code' => '47'),
'NP' => array('name' => 'NEPAL', 'code' => '977'),
'NR' => array('name' => 'NAURU', 'code' => '674'),
'NU' => array('name' => 'NIUE', 'code' => '683'),
'NZ' => array('name' => 'NEW ZEALAND', 'code' => '64'),
'OM' => array('name' => 'OMAN', 'code' => '968'),
'PA' => array('name' => 'PANAMA', 'code' => '507'),
'PE' => array('name' => 'PERU', 'code' => '51'),
'PF' => array('name' => 'FRENCH POLYNESIA', 'code' => '689'),
'PG' => array('name' => 'PAPUA NEW GUINEA', 'code' => '675'),
'PH' => array('name' => 'PHILIPPINES', 'code' => '63'),
'PK' => array('name' => 'PAKISTAN', 'code' => '92'),
'PL' => array('name' => 'POLAND', 'code' => '48'),
'PM' => array('name' => 'SAINT PIERRE AND MIQUELON', 'code' => '508'),
'PN' => array('name' => 'PITCAIRN', 'code' => '870'),
'PR' => array('name' => 'PUERTO RICO', 'code' => '1'),
'PT' => array('name' => 'PORTUGAL', 'code' => '351'),
'PW' => array('name' => 'PALAU', 'code' => '680'),
'PY' => array('name' => 'PARAGUAY', 'code' => '595'),
'QA' => array('name' => 'QATAR', 'code' => '974'),
'RO' => array('name' => 'ROMANIA', 'code' => '40'),
'RS' => array('name' => 'SERBIA', 'code' => '381'),
'RU' => array('name' => 'RUSSIAN FEDERATION', 'code' => '7'),
'RW' => array('name' => 'RWANDA', 'code' => '250'),
'SA' => array('name' => 'SAUDI ARABIA', 'code' => '966'),
'SB' => array('name' => 'SOLOMON ISLANDS', 'code' => '677'),
'SC' => array('name' => 'SEYCHELLES', 'code' => '248'),
'SD' => array('name' => 'SUDAN', 'code' => '249'),
'SE' => array('name' => 'SWEDEN', 'code' => '46'),
'SG' => array('name' => 'SINGAPORE', 'code' => '65'),
'SH' => array('name' => 'SAINT HELENA', 'code' => '290'),
'SI' => array('name' => 'SLOVENIA', 'code' => '386'),
'SK' => array('name' => 'SLOVAKIA', 'code' => '421'),
'SL' => array('name' => 'SIERRA LEONE', 'code' => '232'),
'SM' => array('name' => 'SAN MARINO', 'code' => '378'),
'SN' => array('name' => 'SENEGAL', 'code' => '221'),
'SO' => array('name' => 'SOMALIA', 'code' => '252'),
'SR' => array('name' => 'SURINAME', 'code' => '597'),
'ST' => array('name' => 'SAO TOME AND PRINCIPE', 'code' => '239'),
'SV' => array('name' => 'EL SALVADOR', 'code' => '503'),
'SY' => array('name' => 'SYRIAN ARAB REPUBLIC', 'code' => '963'),
'SZ' => array('name' => 'SWAZILAND', 'code' => '268'),
'TC' => array('name' => 'TURKS AND CAICOS ISLANDS', 'code' => '1649'),
'TD' => array('name' => 'CHAD', 'code' => '235'),
'TG' => array('name' => 'TOGO', 'code' => '228'),
'TH' => array('name' => 'THAILAND', 'code' => '66'),
'TJ' => array('name' => 'TAJIKISTAN', 'code' => '992'),
'TK' => array('name' => 'TOKELAU', 'code' => '690'),
'TL' => array('name' => 'TIMOR-LESTE', 'code' => '670'),
'TM' => array('name' => 'TURKMENISTAN', 'code' => '993'),
'TN' => array('name' => 'TUNISIA', 'code' => '216'),
'TO' => array('name' => 'TONGA', 'code' => '676'),
'TR' => array('name' => 'TURKEY', 'code' => '90'),
'TT' => array('name' => 'TRINIDAD AND TOBAGO', 'code' => '1868'),
'TV' => array('name' => 'TUVALU', 'code' => '688'),
'TW' => array('name' => 'TAIWAN, PROVINCE OF CHINA', 'code' => '886'),
'TZ' => array('name' => 'TANZANIA, UNITED REPUBLIC OF', 'code' => '255'),
'UA' => array('name' => 'UKRAINE', 'code' => '380'),
'UG' => array('name' => 'UGANDA', 'code' => '256'),
'US' => array('name' => 'UNITED STATES', 'code' => '1'),
'UY' => array('name' => 'URUGUAY', 'code' => '598'),
'UZ' => array('name' => 'UZBEKISTAN', 'code' => '998'),
'VA' => array('name' => 'HOLY SEE (VATICAN CITY STATE)', 'code' => '39'),
'VC' => array('name' => 'SAINT VINCENT AND THE GRENADINES', 'code' => '1784'),
'VE' => array('name' => 'VENEZUELA', 'code' => '58'),
'VG' => array('name' => 'VIRGIN ISLANDS, BRITISH', 'code' => '1284'),
'VI' => array('name' => 'VIRGIN ISLANDS, U.S.', 'code' => '1340'),
'VN' => array('name' => 'VIET NAM', 'code' => '84'),
'VU' => array('name' => 'VANUATU', 'code' => '678'),
'WF' => array('name' => 'WALLIS AND FUTUNA', 'code' => '681'),
'WS' => array('name' => 'SAMOA', 'code' => '685'),
'XK' => array('name' => 'KOSOVO', 'code' => '381'),
'YE' => array('name' => 'YEMEN', 'code' => '967'),
'YT' => array('name' => 'MAYOTTE', 'code' => '262'),
'ZA' => array('name' => 'SOUTH AFRICA', 'code' => '27'),
'ZM' => array('name' => 'ZAMBIA', 'code' => '260'),
'ZW' => array('name' => 'ZIMBABWE', 'code' => '263')
);
return $countryArray;
}
function email_template_variables()
{
$arry = [
'{first_name}' => 'first_name',
'{last_name}' => 'last_name',
'{zip_code}' => 'zip_code',
'{address}' => 'address',
'{state}' => 'state',
'{city}' => 'city',
'{email}' => 'email',
];
return $arry;
}
function setEnv($key, $value)
{
file_put_contents(app()->environmentFilePath(), str_replace(
$key . '=' . env($value),
$key . '=' . $value,
file_get_contents(app()->environmentFilePath())
));
}
function available_servers(){
return [
'amazon_smtp','amazon_api','google_gmail_smtp','mailchimp_mandrill_smtp','mailchimp_mandrill_api','mailgun_smtp','mailgun_api','mailjet_smtp','mailjet_api','postmark_smtp','postmark_api','sendgrid_smtp','sendgrid_api','sendinblue_smtp','sendinblue_api','ohmysmtp_smtp','ohmysmtp_api','smtp','sendmail'
];
}
function servers_fields($server){
$fields=[];
if($server=='amazon_smtp'){
$fields=[
'username','password'
];
}elseif ($server=='amazon_api'){
$fields=[
'access_key','secret_key'
];
}elseif ($server=='google_gmail_smtp'){
$fields=[
'username','password'
];
}elseif ($server=='mailchimp_mandrill_smtp'){
$fields=[
'username','password'
];
}elseif ($server=='mailchimp_mandrill_api'){
$fields=[
'api_key',
];
}elseif ($server=='mailgun_smtp'){
$fields=[
'username','password'
];
}elseif ($server=='mailgun_api'){
$fields=[
'api_key','domain',
];
}elseif ($server=='mailjet_smtp'){
$fields=[
'access_key','secret_key'
];
}elseif ($server=='mailjet_api'){
$fields=[
'access_key','secret_key'
];
}elseif ($server=='postmark_smtp'){
$fields=[
'postmark_id'
];
}elseif ($server=='postmark_api'){
$fields=[
'api_key'
];
}elseif ($server=='sendgrid_smtp'){
$fields=[
'api_key'
];
}elseif ($server=='sendgrid_api'){
$fields=[
'api_key'
];
}elseif ($server=='sendinblue_smtp'){
$fields=[
'username','password'
];
}elseif ($server=='sendinblue_api'){
$fields=[
'api_key'
];
}elseif ($server=='ohmysmtp_smtp'){
$fields=[
'api_token'
];
}elseif ($server=='ohmysmtp_api'){
$fields=[
'api_token'
];
}elseif ($server=='smtp'){
$fields=[
'hostname','username','password','port','encryption_method'
];
}elseif ($server=='sendmail'){
$fields=[];
}
return $fields;
}
function format_field_name($field){
return ucwords(str_replace('_',' ',$field));
}
function getDomainFromEmail($email){
// make sure we've got a valid email
if( filter_var( $email, FILTER_VALIDATE_EMAIL ) ) {
// split on @ and return last value of array (the domain)
$array = explode('@', $email);
return array_pop($array);
}
return null;
}
function getNameFromEmail($email){
// make sure we've got a valid email
if( filter_var( $email, FILTER_VALIDATE_EMAIL ) ) {
// split on @ and return last value of array (the domain)
$array = explode('@', $email);
return $array[0];
}
return null;
}