Commit cfb950cf authored by Vipul Basapati's avatar Vipul Basapati

Refactored admin.js to es6 linting + removed some unused files

parent 9f05ba48
<?php
namespace App\Helpers\Macros;
use App\Helpers\Macros\Traits\Dropdowns;
use Collective\Html\FormBuilder;
/**
* Class Macros.
*/
class Macros extends FormBuilder
{
use Dropdowns;
}
<?php
namespace App\Helpers\Macros\Traits;
/**
* Class Dropdowns.
*/
trait Dropdowns
{
/**
* Use this to set the default country state type for the shorthand method.
*
* @param $name
* @param null $selected
* @param array $options
*
* @return string
*/
public function selectState($name, $selected = null, $options = [])
{
return $this->selectStateUS($name, $selected, $options);
}
/**
* @param $name
* @param null $selected
* @param array $options
*
* @return string
*/
public function selectStateUS($name, $selected = null, $options = [])
{
$list = [
'' => 'Select One...',
'AL' => 'Alabama',
'AK' => 'Alaska',
'AZ' => 'Arizona',
'AR' => 'Arkansas',
'CA' => 'California',
'CO' => 'Colorado',
'CT' => 'Connecticut',
'DE' => 'Delaware',
'DC' => 'District of Columbia',
'FL' => 'Florida',
'GA' => 'Georgia',
'HI' => 'Hawaii',
'ID' => 'Idaho',
'IL' => 'Illinois',
'IN' => 'Indiana',
'IA' => 'Iowa',
'KS' => 'Kansas',
'KY' => 'Kentucky',
'LA' => 'Louisiana',
'ME' => 'Maine',
'MD' => 'Maryland',
'MA' => 'Massachusetts',
'MI' => 'Michigan',
'MN' => 'Minnesota',
'MS' => 'Mississippi',
'MO' => 'Missouri',
'MT' => 'Montana',
'NE' => 'Nebraska',
'NV' => 'Nevada',
'NH' => 'New Hampshire',
'NJ' => 'New Jersey',
'NM' => 'New Mexico',
'NY' => 'New York',
'NC' => 'North Carolina',
'ND' => 'North Dakota',
'OH' => 'Ohio',
'OK' => 'Oklahoma',
'OR' => 'Oregon',
'PA' => 'Pennsylvania',
'RI' => 'Rhode Island',
'SC' => 'South Carolina',
'SD' => 'South Dakota',
'TN' => 'Tennessee',
'TX' => 'Texas',
'UT' => 'Utah',
'VT' => 'Vermont',
'VA' => 'Virginia',
'WA' => 'Washington',
'WV' => 'West Virginia',
'WI' => 'Wisconsin',
'WY' => 'Wyoming',
];
return $this->select($name, $list, $selected, $options);
}
/**
* @param $name
* @param null $selected
* @param array $options
*
* @return mixed
*/
public function selectStateUSOutlyingTerritories($name, $selected = null, $options = [])
{
$list = [
'' => 'Select One...',
'AS' => 'American Samoa',
'GU' => 'Guam',
'MP' => 'Northern Mariana Islands',
'PR' => 'Puerto Rico',
'UM' => 'United States Minor Outlying Islands',
'VI' => 'Virgin Islands',
];
return $this->select($name, $list, $selected, $options);
}
/**
* @param $name
* @param null $selected
* @param array $options
*
* @return mixed
*/
public function selectStateUSArmedForces($name, $selected = null, $options = [])
{
$list = [
'' => 'Select One...',
'AA' => 'Armed Forces Americas',
'AP' => 'Armed Forces Pacific',
'AE' => 'Armed Forces Others',
];
return $this->select($name, $list, $selected, $options);
}
/**
* @param $name
* @param null $selected
* @param array $options
*
* @return mixed
*/
public function selectCanadaTerritories($name, $selected = null, $options = [])
{
$list = [
'' => 'Select One...',
'AB' => 'Alberta',
'BC' => 'British Columbia',
'MB' => 'Manitoba',
'NB' => 'New Brunswick',
'NL' => 'Newfoundland and Labrador',
'NS' => 'Nova Scotia',
'ON' => 'Ontario',
'PE' => 'Prince Edward Island',
'QC' => 'Quebec',
'SK' => 'Saskatchewan',
'NT' => 'Northwest Territories',
'NU' => 'Nunavut',
'YT' => 'Yukon',
];
return $this->select($name, $list, $selected, $options);
}
/**
* @param $name
* @param null $selected
* @param array $options
*
* @return mixed
*/
public function selectStateMexico($name, $selected = null, $options = [])
{
$list = [
'' => 'Select One...',
'DIF' => 'Distrito Federal',
'AGS' => 'Aguascalientes',
'BCN' => 'Baja California',
'BCS' => 'Baja California Sur',
'CAM' => 'Campeche',
'CHP' => 'Chiapas',
'CHI' => 'Chihuahua',
'COA' => 'Coahuila',
'COL' => 'Colima',
'DUR' => 'Durango',
'GTO' => 'Guanajuato',
'GRO' => 'Guerrero',
'HGO' => 'Hidalgo',
'JAL' => 'Jalisco',
'MEX' => 'Mexico',
'MIC' => 'Michoacan',
'MOR' => 'Morelos',
'NAY' => 'Nayarit',
'NLE' => 'Nuevo Le&oacute;n',
'OAX' => 'Oaxaca',
'PUE' => 'Puebla',
'QRO' => 'Queretaro',
'ROO' => 'Quintana Roo',
'SLP' => 'San Luis Potos&iacute;',
'SIN' => 'Sinaloa',
'SON' => 'Sonora',
'TAB' => 'Tabasco',
'TAM' => 'Tamaulipas',
'TLX' => 'Tlaxcala',
'VER' => 'Veracruz',
'YUC' => 'Yucatan',
'ZAC' => 'Zacatecas',
];
return $this->select($name, $list, $selected, $options);
}
/**
* Use this to set the default country dropdown type for the shorthand method.
*
* @param $name
* @param null $selected
* @param array $options
*
* @return string
*/
public function selectCountry($name, $selected = null, $options = [])
{
return $this->selectCountryAlpha2($name, $selected, $options);
}
/**
* @param $name
* @param null $selected
* @param array $options
*
* @return mixed
*/
public function selectCountryAlpha($name, $selected = null, $options = [])
{
$list = [
'' => 'Select One...',
'ISO 3166-2:AF' => 'Afghanistan',
'ISO 3166-2:AX' => 'Åland Islands',
'ISO 3166-2:AL' => 'Albania',
'ISO 3166-2:DZ' => 'Algeria',
'ISO 3166-2:AS' => 'American Samoa',
'ISO 3166-2:AD' => 'Andorra',
'ISO 3166-2:AO' => 'Angola',
'ISO 3166-2:AI' => 'Anguilla',
'ISO 3166-2:AQ' => 'Antarctica',
'ISO 3166-2:AG' => 'Antigua and Barbuda',
'ISO 3166-2:AR' => 'Argentina',
'ISO 3166-2:AM' => 'Armenia',
'ISO 3166-2:AW' => 'Aruba',
'ISO 3166-2:AU' => 'Australia',
'ISO 3166-2:AT' => 'Austria',
'ISO 3166-2:AZ' => 'Azerbaijan',
'ISO 3166-2:BS' => 'Bahamas',
'ISO 3166-2:BH' => 'Bahrain',
'ISO 3166-2:BD' => 'Bangladesh',
'ISO 3166-2:BB' => 'Barbados',
'ISO 3166-2:BY' => 'Belarus',
'ISO 3166-2:BE' => 'Belgium',
'ISO 3166-2:BZ' => 'Belize',
'ISO 3166-2:BJ' => 'Benin',
'ISO 3166-2:BM' => 'Bermuda',
'ISO 3166-2:BT' => 'Bhutan',
'ISO 3166-2:BO' => 'Bolivia, Plurinational State of',
'ISO 3166-2:BQ' => 'Bonaire, Sint Eustatius and Saba',
'ISO 3166-2:BA' => 'Bosnia and Herzegovina',
'ISO 3166-2:BW' => 'Botswana',
'ISO 3166-2:BV' => 'Bouvet Island',
'ISO 3166-2:BR' => 'Brazil',
'ISO 3166-2:IO' => 'British Indian Ocean Territory',
'ISO 3166-2:BN' => 'Brunei Darussalam',
'ISO 3166-2:BG' => 'Bulgaria',
'ISO 3166-2:BF' => 'Burkina Faso',
'ISO 3166-2:BI' => 'Burundi',
'ISO 3166-2:KH' => 'Cambodia',
'ISO 3166-2:CM' => 'Cameroon',
'ISO 3166-2:CA' => 'Canada',
'ISO 3166-2:CV' => 'Cape Verde',
'ISO 3166-2:KY' => 'Cayman Islands',
'ISO 3166-2:CF' => 'Central African Republic',
'ISO 3166-2:TD' => 'Chad',
'ISO 3166-2:CL' => 'Chile',
'ISO 3166-2:CN' => 'China',
'ISO 3166-2:CX' => 'Christmas Island',
'ISO 3166-2:CC' => 'Cocos (Keeling) Islands',
'ISO 3166-2:CO' => 'Colombia',
'ISO 3166-2:KM' => 'Comoros',
'ISO 3166-2:CG' => 'Congo',
'ISO 3166-2:CD' => 'Congo, the Democratic Republic of the',
'ISO 3166-2:CK' => 'Cook Islands',
'ISO 3166-2:CR' => 'Costa Rica',
'ISO 3166-2:CI' => 'Côte d\Ivoire',
'ISO 3166-2:HR' => 'Croatia',
'ISO 3166-2:CU' => 'Cuba',
'ISO 3166-2:CW' => 'Curaçao',
'ISO 3166-2:CY' => 'Cyprus',
'ISO 3166-2:CZ' => 'Czech Republic',
'ISO 3166-2:DK' => 'Denmark',
'ISO 3166-2:DJ' => 'Djibouti',
'ISO 3166-2:DM' => 'Dominica',
'ISO 3166-2:DO' => 'Dominican Republic',
'ISO 3166-2:EC' => 'Ecuador',
'ISO 3166-2:EG' => 'Egypt',
'ISO 3166-2:SV' => 'El Salvador',
'ISO 3166-2:GQ' => 'Equatorial Guinea',
'ISO 3166-2:ER' => 'Eritrea',
'ISO 3166-2:EE' => 'Estonia',
'ISO 3166-2:ET' => 'Ethiopia',
'ISO 3166-2:FK' => 'Falkland Islands (Malvinas)',
'ISO 3166-2:FO' => 'Faroe Islands',
'ISO 3166-2:FJ' => 'Fiji',
'ISO 3166-2:FI' => 'Finland',
'ISO 3166-2:FR' => 'France',
'ISO 3166-2:GF' => 'French Guiana',
'ISO 3166-2:PF' => 'French Polynesia',
'ISO 3166-2:TF' => 'French Southern Territories',
'ISO 3166-2:GA' => 'Gabon',
'ISO 3166-2:GM' => 'Gambia',
'ISO 3166-2:GE' => 'Georgia',
'ISO 3166-2:DE' => 'Germany',
'ISO 3166-2:GH' => 'Ghana',
'ISO 3166-2:GI' => 'Gibraltar',
'ISO 3166-2:GR' => 'Greece',
'ISO 3166-2:GL' => 'Greenland',
'ISO 3166-2:GD' => 'Grenada',
'ISO 3166-2:GP' => 'Guadeloupe',
'ISO 3166-2:GU' => 'Guam',
'ISO 3166-2:GT' => 'Guatemala',
'ISO 3166-2:GG' => 'Guernsey',
'ISO 3166-2:GN' => 'Guinea',
'ISO 3166-2:GW' => 'Guinea-Bissau',
'ISO 3166-2:GY' => 'Guyana',
'ISO 3166-2:HT' => 'Haiti',
'ISO 3166-2:HM' => 'Heard Island and McDonald Islands',
'ISO 3166-2:VA' => 'Holy See (Vatican City State)',
'ISO 3166-2:HN' => 'Honduras',
'ISO 3166-2:HK' => 'Hong Kong',
'ISO 3166-2:HU' => 'Hungary',
'ISO 3166-2:IS' => 'Iceland',
'ISO 3166-2:IN' => 'India',
'ISO 3166-2:ID' => 'Indonesia',
'ISO 3166-2:IR' => 'Iran, Islamic Republic of',
'ISO 3166-2:IQ' => 'Iraq',
'ISO 3166-2:IE' => 'Ireland',
'ISO 3166-2:IM' => 'Isle of Man',
'ISO 3166-2:IL' => 'Israel',
'ISO 3166-2:IT' => 'Italy',
'ISO 3166-2:JM' => 'Jamaica',
'ISO 3166-2:JP' => 'Japan',
'ISO 3166-2:JE' => 'Jersey',
'ISO 3166-2:JO' => 'Jordan',
'ISO 3166-2:KZ' => 'Kazakhstan',
'ISO 3166-2:KE' => 'Kenya',
'ISO 3166-2:KI' => 'Kiribati',
'ISO 3166-2:KP' => 'Korea, Democratic People\'s Republic of',
'ISO 3166-2:KR' => 'Korea, Republic of',
'ISO 3166-2:KW' => 'Kuwait',
'ISO 3166-2:KG' => 'Kyrgyzstan',
'ISO 3166-2:LA' => 'Lao People\'s Democratic Republic',
'ISO 3166-2:LV' => 'Latvia',
'ISO 3166-2:LB' => 'Lebanon',
'ISO 3166-2:LS' => 'Lesotho',
'ISO 3166-2:LR' => 'Liberia',
'ISO 3166-2:LY' => 'Libya',
'ISO 3166-2:LI' => 'Liechtenstein',
'ISO 3166-2:LT' => 'Lithuania',
'ISO 3166-2:LU' => 'Luxembourg',
'ISO 3166-2:MO' => 'Macao',
'ISO 3166-2:MK' => 'Macedonia, the former Yugoslav Republic of',
'ISO 3166-2:MG' => 'Madagascar',
'ISO 3166-2:MW' => 'Malawi',
'ISO 3166-2:MY' => 'Malaysia',
'ISO 3166-2:MV' => 'Maldives',
'ISO 3166-2:ML' => 'Mali',
'ISO 3166-2:MT' => 'Malta',
'ISO 3166-2:MH' => 'Marshall Islands',
'ISO 3166-2:MQ' => 'Martinique',
'ISO 3166-2:MR' => 'Mauritania',
'ISO 3166-2:MU' => 'Mauritius',
'ISO 3166-2:YT' => 'Mayotte',
'ISO 3166-2:MX' => 'Mexico',
'ISO 3166-2:FM' => 'Micronesia, Federated States of',
'ISO 3166-2:MD' => 'Moldova, Republic of',
'ISO 3166-2:MC' => 'Monaco',
'ISO 3166-2:MN' => 'Mongolia',
'ISO 3166-2:ME' => 'Montenegro',
'ISO 3166-2:MS' => 'Montserrat',
'ISO 3166-2:MA' => 'Morocco',
'ISO 3166-2:MZ' => 'Mozambique',
'ISO 3166-2:MM' => 'Myanmar',
'ISO 3166-2:NA' => 'Namibia',
'ISO 3166-2:NR' => 'Nauru',
'ISO 3166-2:NP' => 'Nepal',
'ISO 3166-2:NL' => 'Netherlands',
'ISO 3166-2:NC' => 'New Caledonia',
'ISO 3166-2:NZ' => 'New Zealand',
'ISO 3166-2:NI' => 'Nicaragua',
'ISO 3166-2:NE' => 'Niger',
'ISO 3166-2:NG' => 'Nigeria',
'ISO 3166-2:NU' => 'Niue',
'ISO 3166-2:NF' => 'Norfolk Island',
'ISO 3166-2:MP' => 'Northern Mariana Islands',
'ISO 3166-2:NO' => 'Norway',
'ISO 3166-2:OM' => 'Oman',
'ISO 3166-2:PK' => 'Pakistan',
'ISO 3166-2:PW' => 'Palau',
'ISO 3166-2:PS' => 'Palestinian Territory, Occupied',
'ISO 3166-2:PA' => 'Panama',
'ISO 3166-2:PG' => 'Papua New Guinea',
'ISO 3166-2:PY' => 'Paraguay',
'ISO 3166-2:PE' => 'Peru',
'ISO 3166-2:PH' => 'Philippines',
'ISO 3166-2:PN' => 'Pitcairn',
'ISO 3166-2:PL' => 'Poland',
'ISO 3166-2:PT' => 'Portugal',
'ISO 3166-2:PR' => 'Puerto Rico',
'ISO 3166-2:QA' => 'Qatar',
'ISO 3166-2:RE' => 'Réunion',
'ISO 3166-2:RO' => 'Romania',
'ISO 3166-2:RU' => 'Russian Federation',
'ISO 3166-2:RW' => 'Rwanda',
'ISO 3166-2:BL' => 'Saint Barthélemy',
'ISO 3166-2:SH' => 'Saint Helena, Ascension and Tristan da Cunha',
'ISO 3166-2:KN' => 'Saint Kitts and Nevis',
'ISO 3166-2:LC' => 'Saint Lucia',
'ISO 3166-2:MF' => 'Saint Martin (French part)',
'ISO 3166-2:PM' => 'Saint Pierre and Miquelon',
'ISO 3166-2:VC' => 'Saint Vincent and the Grenadines',
'ISO 3166-2:WS' => 'Samoa',
'ISO 3166-2:SM' => 'San Marino',
'ISO 3166-2:ST' => 'Sao Tome and Principe',
'ISO 3166-2:SA' => 'Saudi Arabia',
'ISO 3166-2:SN' => 'Senegal',
'ISO 3166-2:RS' => 'Serbia',
'ISO 3166-2:SC' => 'Seychelles',
'ISO 3166-2:SL' => 'Sierra Leone',
'ISO 3166-2:SG' => 'Singapore',
'ISO 3166-2:SX' => 'Sint Maarten (Dutch part)',
'ISO 3166-2:SK' => 'Slovakia',
'ISO 3166-2:SI' => 'Slovenia',
'ISO 3166-2:SB' => 'Solomon Islands',
'ISO 3166-2:SO' => 'Somalia',
'ISO 3166-2:ZA' => 'South Africa',
'ISO 3166-2:GS' => 'South Georgia and the South Sandwich Islands',
'ISO 3166-2:SS' => 'South Sudan',
'ISO 3166-2:ES' => 'Spain',
'ISO 3166-2:LK' => 'Sri Lanka',
'ISO 3166-2:SD' => 'Sudan',
'ISO 3166-2:SR' => 'Suriname',
'ISO 3166-2:SJ' => 'Svalbard and Jan Mayen',
'ISO 3166-2:SZ' => 'Swaziland',
'ISO 3166-2:SE' => 'Sweden',
'ISO 3166-2:CH' => 'Switzerland',
'ISO 3166-2:SY' => 'Syrian Arab Republic',
'ISO 3166-2:TW' => 'Taiwan, Province of China',
'ISO 3166-2:TJ' => 'Tajikistan',
'ISO 3166-2:TZ' => 'Tanzania, United Republic of',
'ISO 3166-2:TH' => 'Thailand',
'ISO 3166-2:TL' => 'Timor-Leste',
'ISO 3166-2:TG' => 'Togo',
'ISO 3166-2:TK' => 'Tokelau',
'ISO 3166-2:TO' => 'Tonga',
'ISO 3166-2:TT' => 'Trinidad and Tobago',
'ISO 3166-2:TN' => 'Tunisia',
'ISO 3166-2:TR' => 'Turkey',
'ISO 3166-2:TM' => 'Turkmenistan',
'ISO 3166-2:TC' => 'Turks and Caicos Islands',
'ISO 3166-2:TV' => 'Tuvalu',
'ISO 3166-2:UG' => 'Uganda',
'ISO 3166-2:UA' => 'Ukraine',
'ISO 3166-2:AE' => 'United Arab Emirates',
'ISO 3166-2:GB' => 'United Kingdom',
'ISO 3166-2:US' => 'United States',
'ISO 3166-2:UM' => 'United States Minor Outlying Islands',
'ISO 3166-2:UY' => 'Uruguay',
'ISO 3166-2:UZ' => 'Uzbekistan',
'ISO 3166-2:VU' => 'Vanuatu',
'ISO 3166-2:VE' => 'Venezuela, Bolivarian Republic of',
'ISO 3166-2:VN' => 'Viet Nam',
'ISO 3166-2:VG' => 'Virgin Islands, British',
'ISO 3166-2:VI' => 'Virgin Islands, U.S.',
'ISO 3166-2:WF' => 'Wallis and Futuna',
'ISO 3166-2:EH' => 'Western Sahara',
'ISO 3166-2:YE' => 'Yemen',
'ISO 3166-2:ZM' => 'Zambia',
'ISO 3166-2:ZW' => 'Zimbabwe',
];
return $this->select($name, $list, $selected, $options);
}
/**
* @param $name
* @param null $selected
* @param array $options
*
* @return string
*/
public function selectCountryAlpha2($name, $selected = null, $options = [])
{
$list = [
'' => 'Select One...',
'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, The Democratic Republic of The',
'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 and 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',
'KP' => 'Korea, Democratic People\'s Republic of',
'KR' => 'Korea, Republic of',
'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, The Former Yugoslav Republic of',
'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, Republic of',
'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',
'SH' => 'Saint Helena',
'KN' => 'Saint Kitts and Nevis',
'LC' => 'Saint Lucia',
'PM' => 'Saint Pierre and Miquelon',
'VC' => 'Saint Vincent and The 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 The South Sandwich Islands',
'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, Province of China',
'TJ' => 'Tajikistan',
'TZ' => 'Tanzania, United Republic of',
'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 Minor 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 $this->select($name, $list, $selected, $options);
}
/**
* @param $name
* @param null $selected
* @param array $options
*
* @return string
*/
public function selectCountryAlpha3($name, $selected = null, $options = [])
{
$list = [
'' => 'Select One...',
'AFG' => 'Afghanistan',
'ALA' => 'Åland Islands',
'ALB' => 'Albania',
'DZA' => 'Algeria',
'ASM' => 'American Samoa',
'AND' => 'Andorra',
'AGO' => 'Angola',
'AIA' => 'Anguilla',
'ATA' => 'Antarctica',
'ATG' => 'Antigua and Barbuda',
'ARG' => 'Argentina',
'ARM' => 'Armenia',
'ABW' => 'Aruba',
'AUS' => 'Australia',
'AUT' => 'Austria',
'AZE' => 'Azerbaijan',
'BHS' => 'Bahamas',
'BHR' => 'Bahrain',
'BGD' => 'Bangladesh',
'BRB' => 'Barbados',
'BLR' => 'Belarus',
'BEL' => 'Belgium',
'BLZ' => 'Belize',
'BEN' => 'Benin',
'BMU' => 'Bermuda',
'BTN' => 'Bhutan',
'BOL' => 'Bolivia, Plurinational State of',
'BES' => 'Bonaire, Sint Eustatius and Saba',
'BIH' => 'Bosnia and Herzegovina',
'BWA' => 'Botswana',
'BVT' => 'Bouvet Island',
'BRA' => 'Brazil',
'IOT' => 'British Indian Ocean Territory',
'BRN' => 'Brunei Darussalam',
'BGR' => 'Bulgaria',
'BFA' => 'Burkina Faso',
'BDI' => 'Burundi',
'KHM' => 'Cambodia',
'CMR' => 'Cameroon',
'CAN' => 'Canada',
'CPV' => 'Cape Verde',
'CYM' => 'Cayman Islands',
'CAF' => 'Central African Republic',
'TCD' => 'Chad',
'CHL' => 'Chile',
'CHN' => 'China',
'CXR' => 'Christmas Island',
'CCK' => 'Cocos (Keeling) Islands',
'COL' => 'Colombia',
'COM' => 'Comoros',
'COG' => 'Congo',
'COD' => 'Congo, the Democratic Republic of the',
'COK' => 'Cook Islands',
'CRI' => 'Costa Rica',
'CIV' => 'Côte d\'Ivoire',
'HRV' => 'Croatia',
'CUB' => 'Cuba',
'CUW' => 'Curaçao',
'CYP' => 'Cyprus',
'CZE' => 'Czech Republic',
'DNK' => 'Denmark',
'DJI' => 'Djibouti',
'DMA' => 'Dominica',
'DOM' => 'Dominican Republic',
'ECU' => 'Ecuador',
'EGY' => 'Egypt',
'SLV' => 'El Salvador',
'GNQ' => 'Equatorial Guinea',
'ERI' => 'Eritrea',
'EST' => 'Estonia',
'ETH' => 'Ethiopia',
'FLK' => 'Falkland Islands (Malvinas)',
'FRO' => 'Faroe Islands',
'FJI' => 'Fiji',
'FIN' => 'Finland',
'FRA' => 'France',
'GUF' => 'French Guiana',
'PYF' => 'French Polynesia',
'ATF' => 'French Southern Territories',
'GAB' => 'Gabon',
'GMB' => 'Gambia',
'GEO' => 'Georgia',
'DEU' => 'Germany',
'GHA' => 'Ghana',
'GIB' => 'Gibraltar',
'GRC' => 'Greece',
'GRL' => 'Greenland',
'GRD' => 'Grenada',
'GLP' => 'Guadeloupe',
'GUM' => 'Guam',
'GTM' => 'Guatemala',
'GGY' => 'Guernsey',
'GIN' => 'Guinea',
'GNB' => 'Guinea-Bissau',
'GUY' => 'Guyana',
'HTI' => 'Haiti',
'HMD' => 'Heard Island and McDonald Islands',
'VAT' => 'Holy See (Vatican City State)',
'HND' => 'Honduras',
'HKG' => 'Hong Kong',
'HUN' => 'Hungary',
'ISL' => 'Iceland',
'IND' => 'India',
'IDN' => 'Indonesia',
'IRN' => 'Iran, Islamic Republic of',
'IRQ' => 'Iraq',
'IRL' => 'Ireland',
'IMN' => 'Isle of Man',
'ISR' => 'Israel',
'ITA' => 'Italy',
'JAM' => 'Jamaica',
'JPN' => 'Japan',
'JEY' => 'Jersey',
'JOR' => 'Jordan',
'KAZ' => 'Kazakhstan',
'KEN' => 'Kenya',
'KIR' => 'Kiribati',
'PRK' => 'Korea, Democratic People\'s Republic of',
'KOR' => 'Korea, Republic of',
'KWT' => 'Kuwait',
'KGZ' => 'Kyrgyzstan',
'LAO' => 'Lao People\'s Democratic Republic',
'LVA' => 'Latvia',
'LBN' => 'Lebanon',
'LSO' => 'Lesotho',
'LBR' => 'Liberia',
'LBY' => 'Libya',
'LIE' => 'Liechtenstein',
'LTU' => 'Lithuania',
'LUX' => 'Luxembourg',
'MAC' => 'Macao',
'MKD' => 'Macedonia, the former Yugoslav Republic of',
'MDG' => 'Madagascar',
'MWI' => 'Malawi',
'MYS' => 'Malaysia',
'MDV' => 'Maldives',
'MLI' => 'Mali',
'MLT' => 'Malta',
'MHL' => 'Marshall Islands',
'MTQ' => 'Martinique',
'MRT' => 'Mauritania',
'MUS' => 'Mauritius',
'MYT' => 'Mayotte',
'MEX' => 'Mexico',
'FSM' => 'Micronesia, Federated States of',
'MDA' => 'Moldova, Republic of',
'MCO' => 'Monaco',
'MNG' => 'Mongolia',
'MNE' => 'Montenegro',
'MSR' => 'Montserrat',
'MAR' => 'Morocco',
'MOZ' => 'Mozambique',
'MMR' => 'Myanmar',
'NAM' => 'Namibia',
'NRU' => 'Nauru',
'NPL' => 'Nepal',
'NLD' => 'Netherlands',
'NCL' => 'New Caledonia',
'NZL' => 'New Zealand',
'NIC' => 'Nicaragua',
'NER' => 'Niger',
'NGA' => 'Nigeria',
'NIU' => 'Niue',
'NFK' => 'Norfolk Island',
'MNP' => 'Northern Mariana Islands',
'NOR' => 'Norway',
'OMN' => 'Oman',
'PAK' => 'Pakistan',
'PLW' => 'Palau',
'PSE' => 'Palestinian Territory, Occupied',
'PAN' => 'Panama',
'PNG' => 'Papua New Guinea',
'PRY' => 'Paraguay',
'PER' => 'Peru',
'PHL' => 'Philippines',
'PCN' => 'Pitcairn',
'POL' => 'Poland',
'PRT' => 'Portugal',
'PRI' => 'Puerto Rico',
'QAT' => 'Qatar',
'REU' => 'Réunion',
'ROU' => 'Romania',
'RUS' => 'Russian Federation',
'RWA' => 'Rwanda',
'BLM' => 'Saint Barthélemy',
'SHN' => 'Saint Helena, Ascension and Tristan da Cunha',
'KNA' => 'Saint Kitts and Nevis',
'LCA' => 'Saint Lucia',
'MAF' => 'Saint Martin (French part)',
'SPM' => 'Saint Pierre and Miquelon',
'VCT' => 'Saint Vincent and the Grenadines',
'WSM' => 'Samoa',
'SMR' => 'San Marino',
'STP' => 'Sao Tome and Principe',
'SAU' => 'Saudi Arabia',
'SEN' => 'Senegal',
'SRB' => 'Serbia',
'SYC' => 'Seychelles',
'SLE' => 'Sierra Leone',
'SGP' => 'Singapore',
'SXM' => 'Sint Maarten (Dutch part)',
'SVK' => 'Slovakia',
'SVN' => 'Slovenia',
'SLB' => 'Solomon Islands',
'SOM' => 'Somalia',
'ZAF' => 'South Africa',
'SGS' => 'South Georgia and the South Sandwich Islands',
'SSD' => 'South Sudan',
'ESP' => 'Spain',
'LKA' => 'Sri Lanka',
'SDN' => 'Sudan',
'SUR' => 'Suriname',
'SJM' => 'Svalbard and Jan Mayen',
'SWZ' => 'Swaziland',
'SWE' => 'Sweden',
'CHE' => 'Switzerland',
'SYR' => 'Syrian Arab Republic',
'TWN' => 'Taiwan, Province of China',
'TJK' => 'Tajikistan',
'TZA' => 'Tanzania, United Republic of',
'THA' => 'Thailand',
'TLS' => 'Timor-Leste',
'TGO' => 'Togo',
'TKL' => 'Tokelau',
'TON' => 'Tonga',
'TTO' => 'Trinidad and Tobago',
'TUN' => 'Tunisia',
'TUR' => 'Turkey',
'TKM' => 'Turkmenistan',
'TCA' => 'Turks and Caicos Islands',
'TUV' => 'Tuvalu',
'UGA' => 'Uganda',
'UKR' => 'Ukraine',
'ARE' => 'United Arab Emirates',
'GBR' => 'United Kingdom',
'USA' => 'United States',
'UMI' => 'United States Minor Outlying Islands',
'URY' => 'Uruguay',
'UZB' => 'Uzbekistan',
'VUT' => 'Vanuatu',
'VEN' => 'Venezuela, Bolivarian Republic of',
'VNM' => 'Viet Nam',
'VGB' => 'Virgin Islands, British',
'VIR' => 'Virgin Islands, U.S.',
'WLF' => 'Wallis and Futuna',
'ESH' => 'Western Sahara',
'YEM' => 'Yemen',
'ZMB' => 'Zambia',
'ZWE' => 'Zimbabwe',
];
return $this->select($name, $list, $selected, $options);
}
/**
* @param $name
* @param null $selected
* @param array $options
*
* @return string
*/
public function selectCountryNumeric($name, $selected = null, $options = [])
{
$list = [
'' => 'Select One...',
'4' => 'Afghanistan',
'248' => 'Åland Islands',
'8' => 'Albania',
'12' => 'Algeria',
'16' => 'American Samoa',
'20' => 'Andorra',
'24' => 'Angola',
'660' => 'Anguilla',
'10' => 'Antarctica',
'28' => 'Antigua and Barbuda',
'32' => 'Argentina',
'51' => 'Armenia',
'533' => 'Aruba',
'36' => 'Australia',
'40' => 'Austria',
'31' => 'Azerbaijan',
'44' => 'Bahamas',
'48' => 'Bahrain',
'50' => 'Bangladesh',
'52' => 'Barbados',
'112' => 'Belarus',
'56' => 'Belgium',
'84' => 'Belize',
'204' => 'Benin',
'60' => 'Bermuda',
'64' => 'Bhutan',
'68' => 'Bolivia, Plurinational State of',
'535' => 'Bonaire, Sint Eustatius and Saba',
'70' => 'Bosnia and Herzegovina',
'72' => 'Botswana',
'74' => 'Bouvet Island',
'76' => 'Brazil',
'86' => 'British Indian Ocean Territory',
'96' => 'Brunei Darussalam',
'100' => 'Bulgaria',
'854' => 'Burkina Faso',
'108' => 'Burundi',
'116' => 'Cambodia',
'120' => 'Cameroon',
'124' => 'Canada',
'132' => 'Cape Verde',
'136' => 'Cayman Islands',
'140' => 'Central African Republic',
'148' => 'Chad',
'152' => 'Chile',
'156' => 'China',
'162' => 'Christmas Island',
'166' => 'Cocos (Keeling) Islands',
'170' => 'Colombia',
'174' => 'Comoros',
'178' => 'Congo',
'180' => 'Congo, the Democratic Republic of the',
'184' => 'Cook Islands',
'188' => 'Costa Rica',
'384' => 'Côte d\'Ivoire',
'191' => 'Croatia',
'192' => 'Cuba',
'531' => 'Curaçao',
'196' => 'Cyprus',
'203' => 'Czech Republic',
'208' => 'Denmark',
'262' => 'Djibouti',
'212' => 'Dominica',
'214' => 'Dominican Republic',
'218' => 'Ecuador',
'818' => 'Egypt',
'222' => 'El Salvador',
'226' => 'Equatorial Guinea',
'232' => 'Eritrea',
'233' => 'Estonia',
'231' => 'Ethiopia',
'238' => 'Falkland Islands (Malvinas)',
'234' => 'Faroe Islands',
'242' => 'Fiji',
'246' => 'Finland',
'250' => 'France',
'254' => 'French Guiana',
'258' => 'French Polynesia',
'260' => 'French Southern Territories',
'266' => 'Gabon',
'270' => 'Gambia',
'268' => 'Georgia',
'276' => 'Germany',
'288' => 'Ghana',
'292' => 'Gibraltar',
'300' => 'Greece',
'304' => 'Greenland',
'308' => 'Grenada',
'312' => 'Guadeloupe',
'316' => 'Guam',
'320' => 'Guatemala',
'831' => 'Guernsey',
'324' => 'Guinea',
'624' => 'Guinea-Bissau',
'328' => 'Guyana',
'332' => 'Haiti',
'334' => 'Heard Island and McDonald Islands',
'336' => 'Holy See (Vatican City State)',
'340' => 'Honduras',
'344' => 'Hong Kong',
'348' => 'Hungary',
'352' => 'Iceland',
'356' => 'India',
'360' => 'Indonesia',
'364' => 'Iran, Islamic Republic of',
'368' => 'Iraq',
'372' => 'Ireland',
'833' => 'Isle of Man',
'376' => 'Israel',
'380' => 'Italy',
'388' => 'Jamaica',
'392' => 'Japan',
'832' => 'Jersey',
'400' => 'Jordan',
'398' => 'Kazakhstan',
'404' => 'Kenya',
'296' => 'Kiribati',
'408' => 'Korea, Democratic People\'s Republic of',
'410' => 'Korea, Republic of',
'414' => 'Kuwait',
'417' => 'Kyrgyzstan',
'418' => 'Lao People\'s Democratic Republic',
'428' => 'Latvia',
'422' => 'Lebanon',
'426' => 'Lesotho',
'430' => 'Liberia',
'434' => 'Libya',
'438' => 'Liechtenstein',
'440' => 'Lithuania',
'442' => 'Luxembourg',
'446' => 'Macao',
'807' => 'Macedonia, the former Yugoslav Republic of',
'450' => 'Madagascar',
'454' => 'Malawi',
'458' => 'Malaysia',
'462' => 'Maldives',
'466' => 'Mali',
'470' => 'Malta',
'584' => 'Marshall Islands',
'474' => 'Martinique',
'478' => 'Mauritania',
'480' => 'Mauritius',
'175' => 'Mayotte',
'484' => 'Mexico',
'583' => 'Micronesia, Federated States of',
'498' => 'Moldova, Republic of',
'492' => 'Monaco',
'496' => 'Mongolia',
'499' => 'Montenegro',
'500' => 'Montserrat',
'504' => 'Morocco',
'508' => 'Mozambique',
'104' => 'Myanmar',
'516' => 'Namibia',
'520' => 'Nauru',
'524' => 'Nepal',
'528' => 'Netherlands',
'540' => 'New Caledonia',
'554' => 'New Zealand',
'558' => 'Nicaragua',
'562' => 'Niger',
'566' => 'Nigeria',
'570' => 'Niue',
'574' => 'Norfolk Island',
'580' => 'Northern Mariana Islands',
'578' => 'Norway',
'512' => 'Oman',
'586' => 'Pakistan',
'585' => 'Palau',
'275' => 'Palestinian Territory, Occupied',
'591' => 'Panama',
'598' => 'Papua New Guinea',
'600' => 'Paraguay',
'604' => 'Peru',
'608' => 'Philippines',
'612' => 'Pitcairn',
'616' => 'Poland',
'620' => 'Portugal',
'630' => 'Puerto Rico',
'634' => 'Qatar',
'638' => 'Réunion',
'642' => 'Romania',
'643' => 'Russian Federation',
'646' => 'Rwanda',
'652' => 'Saint Barthélemy',
'654' => 'Saint Helena, Ascension and Tristan da Cunha',
'659' => 'Saint Kitts and Nevis',
'662' => 'Saint Lucia',
'663' => 'Saint Martin (French part)',
'666' => 'Saint Pierre and Miquelon',
'670' => 'Saint Vincent and the Grenadines',
'882' => 'Samoa',
'674' => 'San Marino',
'678' => 'Sao Tome and Principe',
'682' => 'Saudi Arabia',
'686' => 'Senegal',
'688' => 'Serbia',
'690' => 'Seychelles',
'694' => 'Sierra Leone',
'702' => 'Singapore',
'534' => 'Sint Maarten (Dutch part)',
'703' => 'Slovakia',
'705' => 'Slovenia',
'90' => 'Solomon Islands',
'706' => 'Somalia',
'710' => 'South Africa',
'239' => 'South Georgia and the South Sandwich Islands',
'728' => 'South Sudan',
'724' => 'Spain',
'144' => 'Sri Lanka',
'729' => 'Sudan',
'740' => 'Suriname',
'744' => 'Svalbard and Jan Mayen',
'748' => 'Swaziland',
'752' => 'Sweden',
'756' => 'Switzerland',
'760' => 'Syrian Arab Republic',
'158' => 'Taiwan, Province of China',
'762' => 'Tajikistan',
'834' => 'Tanzania, United Republic of',
'764' => 'Thailand',
'626' => 'Timor-Leste',
'768' => 'Togo',
'772' => 'Tokelau',
'776' => 'Tonga',
'780' => 'Trinidad and Tobago',
'788' => 'Tunisia',
'792' => 'Turkey',
'795' => 'Turkmenistan',
'796' => 'Turks and Caicos Islands',
'798' => 'Tuvalu',
'800' => 'Uganda',
'804' => 'Ukraine',
'784' => 'United Arab Emirates',
'826' => 'United Kingdom',
'840' => 'United States',
'581' => 'United States Minor Outlying Islands',
'858' => 'Uruguay',
'860' => 'Uzbekistan',
'548' => 'Vanuatu',
'862' => 'Venezuela, Bolivarian Republic of',
'704' => 'Viet Nam',
'92' => 'Virgin Islands, British',
'850' => 'Virgin Islands, U.S.',
'876' => 'Wallis and Futuna',
'732' => 'Western Sahara',
'887' => 'Yemen',
'894' => 'Zambia',
'716' => 'Zimbabwe',
];
return $this->select($name, $list, $selected, $options);
}
/**
* @param $name
* @param null $selected
* @param array $options
*
* @return mixed
*/
public function selectTimezone($name, $selected = null, $options = [])
{
$list = [];
$utc = new \DateTimeZone('UTC');
$dt = new \DateTime('now', $utc);
foreach (\DateTimeZone::listIdentifiers() as $tz) {
$current_tz = new \DateTimeZone($tz);
$offset = $current_tz->getOffset($dt);
$transition = $current_tz->getTransitions($dt->getTimestamp(), $dt->getTimestamp());
$abbr = $transition[0]['abbr'];
$list[$tz] = $tz.' ['.$abbr.' '.$this->formatOffset($offset).']';
}
return $this->select($name, $list, $selected, $options);
}
/**
* @param $offset
*
* @return string
*/
private function formatOffset($offset)
{
$hours = $offset / 3600;
$remainder = $offset % 3600;
$sign = $hours > 0 ? '+' : '-';
$hour = (int) abs($hours);
$minutes = (int) abs($remainder / 60);
if ($hour == 0 && $minutes == 0) {
$sign = ' ';
}
return $sign.str_pad($hour, 2, '0', STR_PAD_LEFT).':'.str_pad($minutes, 2, '0');
}
}
<?php
/**
* Represents a universally unique identifier (UUID), according to RFC 4122.
*
* This class provides the static methods `uuid3()`, `uuid4()`, and
* `uuid5()` for generating version 3, 4, and 5 UUIDs as specified in RFC 4122.
*
* If all you want is a unique ID, you should call `uuid4()`.
*
* @link http://tools.ietf.org/html/rfc4122
* @link http://en.wikipedia.org/wiki/Universally_unique_identifier
* @link http://www.php.net/manual/en/function.uniqid.php#94959
*/
namespace App\Helpers;
class uuid
{
/**
* When this namespace is specified, the name string is a fully-qualified domain name.
*
* @link http://tools.ietf.org/html/rfc4122#appendix-C
*/
const NAMESPACE_DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';
/**
* When this namespace is specified, the name string is a URL.
*
* @link http://tools.ietf.org/html/rfc4122#appendix-C
*/
const NAMESPACE_URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';
/**
* When this namespace is specified, the name string is an ISO OID.
*
* @link http://tools.ietf.org/html/rfc4122#appendix-C
*/
const NAMESPACE_OID = '6ba7b812-9dad-11d1-80b4-00c04fd430c8';
/**
* When this namespace is specified, the name string is an X.500 DN in DER or a text output format.
*
* @link http://tools.ietf.org/html/rfc4122#appendix-C
*/
const NAMESPACE_X500 = '6ba7b814-9dad-11d1-80b4-00c04fd430c8';
/**
* The nil UUID is special form of UUID that is specified to have all 128 bits set to zero.
*
* @link http://tools.ietf.org/html/rfc4122#section-4.1.7
*/
const NIL = '00000000-0000-0000-0000-000000000000';
private static function getBytes($uuid)
{
if (!self::isValid($uuid)) {
throw new InvalidArgumentException('Invalid UUID string: '.$uuid);
}
// Get hexadecimal components of UUID
$uhex = str_replace([
'urn:',
'uuid:',
'-',
'{',
'}',
], '', $uuid);
// Binary Value
$ustr = '';
// Convert UUID to bits
for ($i = 0; $i < strlen($uhex); $i += 2) {
$ustr .= chr(hexdec($uhex[$i].$uhex[$i + 1]));
}
return $ustr;
}
private static function uuidFromHash($hash, $version)
{
return sprintf('%08s-%04s-%04x-%04x-%12s',
// 32 bits for "time_low"
substr($hash, 0, 8),
// 16 bits for "time_mid"
substr($hash, 8, 4),
// 16 bits for "time_hi_and_version",
// four most significant bits holds version number
(hexdec(substr($hash, 12, 4)) & 0x0fff) | $version << 12,
// 16 bits, 8 bits for "clk_seq_hi_res",
// 8 bits for "clk_seq_low",
// two most significant bits holds zero and one for variant DCE1.1
(hexdec(substr($hash, 16, 4)) & 0x3fff) | 0x8000,
// 48 bits for "node"
substr($hash, 20, 12));
}
/**
* Generate a version 3 UUID based on the MD5 hash of a namespace identifier
* (which is a UUID) and a name (which is a string).
*
* @param string $namespace The UUID namespace in which to create the named UUID
* @param string $name The name to create a UUID for
*
* @return string
*/
public static function uuid3($namespace, $name)
{
$nbytes = self::getBytes($namespace);
// Calculate hash value
$hash = md5($nbytes.$name);
return self::uuidFromHash($hash, 3);
}
/**
* Generate a version 4 (random) UUID.
*
* @return string
*/
public static function uuid4()
{
$bytes = function_exists('random_bytes') ? random_bytes(16) : openssl_random_pseudo_bytes(16);
$hash = bin2hex($bytes);
return self::uuidFromHash($hash, 4);
}
/**
* Generate a version 5 UUID based on the SHA-1 hash of a namespace
* identifier (which is a UUID) and a name (which is a string).
*
* @param string $namespace The UUID namespace in which to create the named UUID
* @param string $name The name to create a UUID for
*
* @return string
*/
public static function uuid5($namespace, $name)
{
$nbytes = self::getBytes($namespace);
// Calculate hash value
$hash = sha1($nbytes.$name);
return self::uuidFromHash($hash, 5);
}
/**
* Check if a string is a valid UUID.
*
* @param string $uuid The string UUID to test
*
* @return bool
*/
public static function isValid($uuid)
{
return preg_match('/^(urn:)?(uuid:)?(\{)?[0-9a-f]{8}\-?[0-9a-f]{4}\-?[0-9a-f]{4}\-?[0-9a-f]{4}\-?[0-9a-f]{12}(?(3)\}|)$/i', $uuid) === 1;
}
/**
* Check if two UUIDs are equal.
*
* @param string $uuid1 The first UUID to test
* @param string $uuid2 The second UUID to test
*
* @return bool
*/
public static function equals($uuid1, $uuid2)
{
return self::getBytes($uuid1) === self::getBytes($uuid2);
}
}
<?php
namespace App\Providers;
use App\Helpers\Macros\Macros;
use Collective\Html\HtmlServiceProvider;
/**
* Class MacroServiceProvider.
*/
class MacroServiceProvider extends HtmlServiceProvider
{
/**
* Bootstrap the application services.
*
* @return void
*/
public function boot()
{
//
}
/**
* Register the application services.
*
* @return void
*/
public function register()
{
parent::register();
$this->app->singleton('form', function ($app) {
$form = new Macros($app['html'], $app['url'], $app['view'], $app['session.store']->token());
return $form->setSessionStore($app['session.store']);
});
}
}
......@@ -198,7 +198,6 @@ return [
App\Providers\ComposerServiceProvider::class,
App\Providers\EventServiceProvider::class,
App\Providers\HistoryServiceProvider::class,
App\Providers\MacroServiceProvider::class,
App\Providers\RouteServiceProvider::class,
Tymon\JWTAuth\Providers\LaravelServiceProvider::class,
Bvipul\Generator\Provider\CrudGeneratorServiceProvider::class,
......
//common functionalities for all the javascript featueres
var Backend = {}; // common variable used in all the files of the backend
(function (){
(function () {
Backend = {
......@@ -55,10 +55,10 @@ var Backend = {}; // common variable used in all the files of the backend
}
request.open(method, url, true);
request.onloadstart = function() {
request.onloadstart = function () {
loadingIcon.show();
};
request.onloadend = function() {
request.onloadend = function () {
loadingIcon.hide();
};
request.setRequestHeader('X-CSRF-TOKEN', csrf);
......@@ -101,8 +101,7 @@ var Backend = {}; // common variable used in all the files of the backend
* Pages
*
*/
Pages:
{
Pages: {
init: function () {
Backend.tinyMCE.init();
},
......@@ -111,13 +110,12 @@ var Backend = {}; // common variable used in all the files of the backend
/**
* Roles management
*/
Roles:
{
Roles: {
selectors: {
associated: document.querySelector("select[name='associated_permissions']"),
associated_container: document.getElementById("#available-permissions"),
},
init(page) {
init: function (page) {
this.setSelectors();
this.setRolepermission(page);
this.addHandlers();
......@@ -154,8 +152,7 @@ var Backend = {}; // common variable used in all the files of the backend
* Users management
*
*/
Users:
{
Users: {
selectors: {
select2: jQuery(".select2"),
getPremissionURL: "",
......@@ -218,8 +215,10 @@ var Backend = {}; // common variable used in all the files of the backend
}
};
Backend.Utils.ajaxrequest(Backend.Users.selectors.getPremissionURL, "post", { role_id: event.target.value }, Backend.Utils.csrf, callback);
}
Backend.Utils.ajaxrequest(Backend.Users.selectors.getPremissionURL, "post", {
role_id: event.target.value
}, Backend.Utils.csrf, callback);
};
});
if (page == "create") {
Backend.Users.selectors.Role3.click();
......@@ -257,8 +256,7 @@ var Backend = {}; // common variable used in all the files of the backend
*
*/
UserDeleted:
{
UserDeleted: {
selectors: {
AlldeletePerms: document.querySelectorAll("a[name='delete_user_perm']"),
AllrestorePerms: document.querySelectorAll("a[name='restore_user']"),
......@@ -330,8 +328,7 @@ var Backend = {}; // common variable used in all the files of the backend
* Blog
*
*/
Blog:
{
Blog: {
selectors: {
tags: jQuery(".tags"),
categories: jQuery(".categories"),
......@@ -377,15 +374,16 @@ var Backend = {}; // common variable used in all the files of the backend
}
};
Backend.Utils.ajaxrequest(Backend.Blog.selectors.GenerateSlugUrl, "post", { text: url }, Backend.Utils.csrf, callback);
Backend.Utils.ajaxrequest(Backend.Blog.selectors.GenerateSlugUrl, "post", {
text: url
}, Backend.Utils.csrf, callback);
}
};
}
},
Menu:
{
Menu: {
selectors: {
menuItemContainer: jQuery("#menu-items"),
menuItemsData: jQuery(".menu-items-field"),
......@@ -394,16 +392,16 @@ var Backend = {}; // common variable used in all the files of the backend
document: jQuery("document"),
addCustomUrlForm: "#menu-add-custom-url",
addModuleToMenuButton: ".add-module-to-menu",
removeMenuItemButton : ".remove-menu-item",
editMenuItemButton : ".edit-menu-item",
removeMenuItemButton: ".remove-menu-item",
editMenuItemButton: ".edit-menu-item",
formUrl: "",
},
methods: {
getNewId : function(str) {
getNewId: function (str) {
var arr = str.match(/"id":[0-9]+/gi);
if(arr) {
$.each(arr, function(index, item) {
if (arr) {
$.each(arr, function (index, item) {
arr[index] = parseInt(item.replace('"id":', ''));
});
return Math.max.apply(Math, arr) + 1;
......@@ -411,36 +409,34 @@ var Backend = {}; // common variable used in all the files of the backend
return 1;
},
findItemById : function(item, id) {
if(item.id == id) {
findItemById: function (item, id) {
if (item.id == id) {
return item;
}
var found = false;
var foundItem;
if(item.children){
$.each(item.children, function(index, childItem){
if (item.children) {
$.each(item.children, function (index, childItem) {
foundItem = Backend.Menu.methods.findItemById(childItem, id);
if(foundItem)
{
if (foundItem) {
found = true;
return false;
}
});
}
if(found)
{
if (found) {
return foundItem;
}
return null;
},
addMenuItem : function(obj) {
addMenuItem: function (obj) {
Backend.Menu.selectors.menuItemContainer.nestable('add', {
"id": Backend.Menu.methods.getNewId(Backend.Menu.selectors.menuItemsData.val()),
"content": obj.name,
"name": obj.name,
"url": obj.url,
"url_type" : obj.url_type,
"url_type": obj.url_type,
"open_in_new_tab": obj.open_in_new_tab,
"icon": obj.icon,
"view_permission_id": obj.view_permission_id
......@@ -452,7 +448,7 @@ var Backend = {}; // common variable used in all the files of the backend
);
},
editMenuItem : function(obj) {
editMenuItem: function (obj) {
var newObject = {
"id": obj.id,
"content": obj.name,
......@@ -465,11 +461,13 @@ var Backend = {}; // common variable used in all the files of the backend
};
var menuItems = Backend.Menu.selectors.menuItemContainer.nestable('serialise');
var itemData;
$.each(menuItems, function(index, item){
$.each(menuItems, function (index, item) {
itemData = Backend.Menu.methods.findItemById(item, id);
if(itemData) { return false; }
if (itemData) {
return false;
}
});
if(itemData.children) {
if (itemData.children) {
newObject.children = itemData.children;
}
......@@ -492,16 +490,16 @@ var Backend = {}; // common variable used in all the files of the backend
var formName = "_add_custom_url_form";
this.selectors.menuItemContainer.nestable({
callback: function(l, e){
callback: function (l, e) {
this.selectors.menuItemsData.val(JSON.stringify($(l).nestable('serialise')));
},
json: this.selectors.menuItemsData.val(),
includeContent:true,
includeContent: true,
scroll: false,
maxDepth: 10
});
this.selectors.addCustomUrlButton.click(function() {
this.selectors.addCustomUrlButton.click(function () {
var title = context.selectors.addCustomUrlButton.attr("data-header");
context.selectors.modal.find(".modal-title").html(title);
context.selectors.modal.modal("show");
......@@ -518,18 +516,18 @@ var Backend = {}; // common variable used in all the files of the backend
error: function (request) {
//Do Something
}
}
};
Backend.Utils.ajaxrequest(context.selectors.formUrl + "/" + formName, "get", {}, Backend.Utils.csrf, callback);
});
jQuery(document).on("submit", context.selectors.addCustomUrlForm, function(e){
jQuery(document).on("submit", context.selectors.addCustomUrlForm, function (e) {
e.preventDefault();
var formData = jQuery(this).serializeArray().reduce(function(obj, item) {
var formData = jQuery(this).serializeArray().reduce(function (obj, item) {
obj[item.name] = item.value;
return obj;
}, {});
if(formData.name.length > 0) {
if(formData.id.length > 0) {
if (formData.name.length > 0) {
if (formData.id.length > 0) {
context.methods.editMenuItem(formData);
} else {
context.methods.addMenuItem(formData);
......@@ -538,7 +536,7 @@ var Backend = {}; // common variable used in all the files of the backend
}
});
jQuery(document).on("click", context.selectors.addModuleToMenuButton, function(){
jQuery(document).on("click", context.selectors.addModuleToMenuButton, function () {
var dataObj = {
id: $(this).attr("data-id"),
name: $(this).attr("data-name"),
......@@ -546,11 +544,11 @@ var Backend = {}; // common variable used in all the files of the backend
url_type: $(this).attr("data-url_type"),
open_in_new_tab: $(this).attr("data-open_in_new_tab"),
view_permission_id: $(this).attr("data-view_permission_id"),
}
};
context.methods.addMenuItem(dataObj);
});
jQuery(document).on("click", context.selectors.removeMenuItemButton, function() {
jQuery(document).on("click", context.selectors.removeMenuItemButton, function () {
context.selectors.menuItemContainer.nestable('remove', jQuery(this).parents(".dd-item").first().attr("data-id"));
Backend.Menu.selectors.menuItemsData.val(
JSON.stringify(
......@@ -559,16 +557,17 @@ var Backend = {}; // common variable used in all the files of the backend
);
});
jQuery(document).on("click", context.selectors.editMenuItemButton, function() {
jQuery(document).on("click", context.selectors.editMenuItemButton, function () {
id = jQuery(this).parents(".dd-item").first().attr("data-id");
var menuItems = context.selectors.menuItemContainer.nestable('serialise');
var itemData;
$.each(menuItems, function(index, item){
$.each(menuItems, function (index, item) {
itemData = context.methods.findItemById(item, id);
if(itemData) { return false; }
if (itemData) {
return false;
}
});
if(itemData.id != undefined && itemData.id == id)
{
if (itemData.id != undefined && itemData.id == id) {
callback = {
success: function (request) {
if (request.status >= 200 && request.status < 400) {
......@@ -578,8 +577,8 @@ var Backend = {}; // common variable used in all the files of the backend
$(document).find(context.selectors.modal).find(".mi-id").val(itemData.id);
$(document).find(context.selectors.modal).find(".mi-name").val(itemData.name);
$(document).find(context.selectors.modal).find(".mi-url").val(itemData.url);
$(document).find(context.selectors.modal).find(".mi-url_type_"+itemData.url_type).prop("checked", true);
if(itemData.open_in_new_tab == 1) {
$(document).find(context.selectors.modal).find(".mi-url_type_" + itemData.url_type).prop("checked", true);
if (itemData.open_in_new_tab == 1) {
$(document).find(context.selectors.modal).find(".mi-open_in_new_tab").prop("checked", true);
}
$(document).find(context.selectors.modal).find(".mi-icon").val(itemData.icon);
......@@ -591,7 +590,7 @@ var Backend = {}; // common variable used in all the files of the backend
error: function (request) {
//Do Something
}
}
};
Backend.Utils.ajaxrequest(context.selectors.formUrl + "/" + formName, "get", {}, Backend.Utils.csrf, callback);
}
});
......@@ -601,8 +600,7 @@ var Backend = {}; // common variable used in all the files of the backend
/**
* Tiny MCE
*/
tinyMCE:
{
tinyMCE: {
init: function () {
tinymce.init({
path_absolute: "/",
......@@ -648,8 +646,7 @@ var Backend = {}; // common variable used in all the files of the backend
}
},
emailTemplate:
{
emailTemplate: {
selectors: {
emailtemplateSelection: document.querySelector(".select2")
......@@ -694,27 +691,22 @@ var Backend = {}; // common variable used in all the files of the backend
* Faq
*
*/
Faq:
{
selectors:
{
},
Faq: {
selectors: {},
init: function () {
// this.addHandlers();
Backend.tinyMCE.init();
},
addHandlers: function () {
}
addHandlers: function () {}
},
/**
* Profile
*
*/
Profile:
{
Profile: {
selectors: {
},
......@@ -741,10 +733,8 @@ var Backend = {}; // common variable used in all the files of the backend
* for all datatables
*
*/
DataTableSearch:
{ //functionalities related to datable search at all the places
selector: {
},
DataTableSearch: { //functionalities related to datable search at all the places
selector: {},
init: function (dataTable) {
......@@ -793,7 +783,7 @@ var Backend = {}; // common variable used in all the files of the backend
this.selector.columnSearchInput.forEach(function (element) {
element.onkeypress = function (event) {
if (event.keyCode == 13) {
var i = element.getAttribute("data-column") // getting column index
var i = element.getAttribute("data-column"); // getting column index
var v = element.value; // getting search input value
dataTable.api().columns(i).search(v).draw();
}
......@@ -848,8 +838,7 @@ var Backend = {}; // common variable used in all the files of the backend
* Settings
*
*/
Settings:
{
Settings: {
selectors: {
RouteURL: "",
setting: document.getElementById("setting")
......@@ -884,8 +873,7 @@ var Backend = {}; // common variable used in all the files of the backend
if (data == 'logo') {
value = 'logo';
Backend.Utils.addClass(Backend.Settings.selectors.imageRemoveLogo, 'hidden');
}
else {
} else {
value = 'favicon';
Backend.Utils.addClass(Backend.Settings.selectors.imageRemoveFavicon, 'hidden');
}
......@@ -901,7 +889,10 @@ var Backend = {}; // common variable used in all the files of the backend
}
};
Backend.Utils.ajaxrequest(route, "POST", { data: value, _token: Backend.Utils.csrf }, Backend.Utils.csrf, callback);
Backend.Utils.ajaxrequest(route, "POST", {
data: value,
_token: Backend.Utils.csrf
}, Backend.Utils.csrf, callback);
}
});
};
......@@ -910,12 +901,3 @@ var Backend = {}; // common variable used in all the files of the backend
};
})();
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment