Ejemplo n.º 1
0
 function SearchTourOptions()
 {
     $env = env('TAG_OPTION', 'static');
     /////////////////
     // Location    //
     /////////////////
     if (str_is('dynamic', $env)) {
         $data = API::GetDestinationTags();
         $destination = [];
         foreach ($data as $key => $value) {
             $dest = explode('.', $value->tag);
             if (count($dest) > 2) {
                 if (isset($destination[strtolower($dest[count($dest) - 2])])) {
                     $destination[strtolower($dest[count($dest) - 2])][] = $dest[strtolower(count($dest) - 1)];
                 } else {
                     $new = [strtolower($dest[count($dest) - 2]) => [$dest[strtolower(count($dest) - 1)]]];
                     $destination = array_merge($destination, $new);
                 }
             } else {
                 if (isset($destination[strtolower($dest[0])])) {
                     $destination[strtolower($dest[0])][] = strtolower($dest[1]);
                 } else {
                     $new = [strtolower($dest[0]) => [strtolower($dest[1])]];
                     $destination = array_merge($destination, $new);
                 }
             }
         }
     } else {
         $destination['Indonesia'] = ['Aceh', 'Balikpapan', 'Bali', 'Bandung', 'Bangka', 'Banten', 'Belitung', 'Derawan', 'Flores', 'Jakarta', 'Jawa Tengah', 'Jawa Timur', 'Karimun Jawa', 'Kepulauan Riau', 'Lampung', 'Lombok', 'Makassar', 'Malang', 'Maluku', 'Manado', 'Medan', 'Nusa Tenggara Barat', 'Nusa Tenggara Timur', 'Padang', 'Pontianak', 'Pulau Seribu', 'Raja Ampat', 'Riau', 'Semarang', 'Solo', 'Surabaya', 'Wakatobi', 'Yogyakarta'];
         $destination['Asia'] = ['Arab Saudi', 'Brunei Darussalam', 'China', 'Filipina', 'India', 'Israel', 'Jepang', 'Kamboja', 'Kazakhstan', 'Kirgizstan', 'Korea Selatan', 'Laos', 'Malaysia', 'Myanmar', 'Republik Maladewa', 'Singapura', 'Taiwan', 'Thailand', 'Uni Emirat Arab', 'Uzbekistan', 'Vietnam'];
         $destination['Australia'] = ['Gold Coast', 'Melbourne', 'Perth', 'South Australia', 'Sydney'];
         $destination['Eropa'] = ['Austria', 'Armenia', 'Belanda', 'Belgia', 'Denmark', 'Finlandia', 'Georgia', 'Hongaria', 'Inggris', 'Italia', 'Jerman', 'Liechtenstein', 'Luxembourg', 'Monako', 'Norwegia', 'Perancis', 'Polandia', 'Portugal', 'Republik Ceko', 'Rusia', 'Skotlandia', 'Slovakia', 'Spanyol', 'Swedia', 'Swiss', 'Turki', 'Vatican'];
         $destination['Amerika'] = ['Kanada', 'USA'];
         $destination['Oceania'] = ['Hawaii', 'New Zealand'];
         $destination['Afrika'] = ['Kenya', 'Madagaskar', 'Maroko', 'Mesir', 'South Afrika', 'Yordania'];
     }
     $destination_options[] = "Semua Tujuan";
     foreach ($destination as $k => $v) {
         $destination_options[$k] = $k;
         foreach ($v as $v2) {
             $destination_options[strtolower($v2)] = '    ' . $v2;
         }
     }
     ////////////
     // harga //
     ////////////
     $harga[''] = 'Semua harga';
     $harga['1-1000000'] = 'Di bawah Rp. 1.000.000';
     $harga['1000000-2500000'] = 'Rp. 1.000.000 - Rp. 2.500.000';
     $harga['2500000-5000000'] = 'Rp. 2.500.000 - Rp. 5.000.000';
     $harga['5000000-10000000'] = 'Rp. 5.000.000 - Rp. 10.000.000';
     $harga['10000000-20000000'] = 'Rp. 10.000.000 - Rp. 20.000.000';
     $harga['20000000'] = 'Rp. 20.000.000 ke atas';
     ///////////
     // Waktu //
     ///////////
     $period[] = 'Kapanpun';
     for ($i = 0; $i <= 12; $i++) {
         $period[\Carbon\Carbon::parse('first day of this month')->addMonth($i)->format('m-Y')] = \Carbon\Carbon::parse('first day of this month')->addMonth($i)->format('M Y');
     }
     //////////////////
     // Travel Agent //
     //////////////////
     \Debugbar::startMeasure('API: travel_agents', 'API: travel_agents');
     $tmp = json_decode($this->api->get($this->api_url . '/travel_agents?access_token=' . Session::get('access_token'))->getBody());
     \Debugbar::stopMeasure('API: travel_agents');
     $travel_agents[] = "Semua Travel Agent";
     foreach ($tmp->data->data as $travel_agent) {
         $travel_agents[strtoupper(substr($travel_agent->name, 0, 1))][$travel_agent->slug] = str_limit($travel_agent->name, 30);
         $this->travel_agent_ids[$travel_agent->slug] = $travel_agent->_id;
     }
     //////////////
     // Interest //
     //////////////
     \Debugbar::startMeasure('API: tag', 'API: tag');
     $tmp = json_decode($this->api->get($this->api_url . '/tags?type=interest&access_token=' . Session::get('access_token'))->getBody());
     \Debugbar::stopMeasure('API: tag');
     $interest = $tmp->data->data;
     //////////////////////////
     // Assign to global var //
     //////////////////////////
     $this->search_tour_options['destinations'] = $destination_options;
     $this->search_tour_options['harga'] = $harga;
     $this->search_tour_options['period'] = $period;
     $this->search_tour_options['travel_agents'] = $travel_agents;
     $this->search_tour_options['interest'] = $interest;
 }