Example #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;
 }
Example #2
0
 /**
  * Constructor
  *
  * @param Request $request Laravel Request
  */
 public function __construct(Request $request)
 {
     $this->transformer = new UserTransformer();
     $this->repository = new UserRepository();
     parent::__construct($request);
 }
Example #3
0
 static function GetLatestTours($query_data)
 {
     Static::init();
     $query_data['upcoming'] = true;
     $api_response = Cache::remember('latest_tours_' . $query_data['skip'] . '_' . $query_data['take'] . http_build_query($query_data), 20, function () use($query_data) {
         return json_decode(self::$api->get(self::$api_url . '/tours?' . http_build_query(array_merge($query_data, ['access_token' => Session::get('access_token')])))->getBody(), false);
     });
     if ($api_response->status != 'success') {
         return null;
     }
     //////////////////////////////////////////////
     // add cheapest upcoming schedules			//
     //////////////////////////////////////////////
     foreach ($api_response->data->data as $k => $tour) {
         $api_response->data->data[$k]->cheapest_upcoming_schedules = Static::get_cheapest_upcoming_schedules_to_tour($tour);
         $api_response->data->data[$k]->upcoming_schedules = Static::get_upcoming_schedules_to_tour($api_response->data->data[$k]->cheapest_upcoming_schedules);
     }
     return ['count' => $api_response->data->count, 'data' => API::reformat_images($api_response->data->data)];
 }
Example #4
0
 /**
  * Constructor
  *
  * @param Request $request Laravel Request
  */
 public function __construct(Request $request)
 {
     $this->transformer = new SharedFilesTransformers();
     $this->repository = new SharedFilesRepository();
     parent::__construct($request);
 }
Example #5
0
 /**
  * Constructor
  *
  * @param Request $request Laravel Request
  */
 public function __construct(Request $request)
 {
     $this->transformer = new FileTransformer();
     parent::__construct($request);
 }
    /**
     * lock around 20 - next 20
     *
     * @return void
     * @author 
     **/
    public function generateXML()
    {
        \Log::info('Running Sitemap XML Generator @' . date('Y-m-d H:i:s'));
        //////////////
        // GET AT //
        //////////////
        $credentials['grant_type'] = 'client_credential';
        $credentials['key'] = env('CAPCUS_API_KEY', 'asdfghjkl');
        $credentials['secret'] = env('CAPCUS_API_SECRET', 'asdfghjkl');
        $api_url = env('API_URL', 'http://capcusapi');
        $api = new \GuzzleHttp\Client(['base_url' => $api_url]);
        $api_result = json_decode($api->post($api_url . '/authorized/client', ['form_params' => $credentials])->getBody());
        if (str_is('success', $api_result->status)) {
            \Session::put('access_token', $api_result->data->access_token);
            \Session::put('refresh_token', $api_result->data->refresh_token);
            \Session::put('expired_at', $api_result->data->expired_at);
        } else {
            \Log::error('Crontab error access token');
        }
        //////////////
        // API DATA //
        //////////////
        $limit = 50000;
        $query_data['skip'] = 0;
        $query_data['take'] = 50;
        $query_data['scheduled_since'] = date("Y-m-d");
        $query_data['with_travel_agent'] = true;
        $query_data['with_count'] = 1;
        $tours = API::GetLatestTours($query_data);
        $total_tours = $tours['count'];
        $connection = ceil($total_tours / $query_data['take']);
        $total_xml = floor($total_tours / $limit);
        //How many xml made
        foreach (range(0, $total_xml) as $key) {
            $current_tours = [];
            //in every xml made need to make many connection
            foreach (range(0, min($limit / $query_data['take'], $connection)) as $key2 => $value2) {
                $query_data['skip'] = (int) ((ceil($total_tours / $query_data['take']) - $connection) * $query_data['take']);
                $next_tours = API::GetLatestTours($query_data);
                $current_tours = array_merge($current_tours, $next_tours['data']);
                $connection = $connection - 1;
            }
            //get file xml
            $my_file = env('SITEMAP_GENERATOR_TARGET') . '/sitemap' . ($key + 1) . '.xml';
            $handle = fopen($my_file, 'w') or die('Cannot open file:  ' . $my_file);
            //implicitly creates file
            $header = '<?xml version="1.0" encoding="UTF-8"?>
<urlset
      xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
            http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
<!-- created with Free Online Sitemap Generator www.xml-sitemaps.com -->';
            fwrite($handle, $header);
            //re write
            foreach ($current_tours as $key3 => $value3) {
                $data = "\n" . '<url>
	<loc>http://capcus.id/tours/d' . $value3->travel_agent->slug . '/' . \Carbon\Carbon::parse($value3->published_at)->year . '/' . $value3->slug . '</loc>
	<changefreq>always</changefreq>
</url>';
                fwrite($handle, $data);
            }
            $footer = "\n" . '</urlset>';
            fwrite($handle, $footer);
        }
        return true;
    }
Example #7
0
 /**
  * Errors
  */
 function error()
 {
     //////////////////
     // GET FEATURED //
     //////////////////
     $webconfig = API::GetWebConfig();
     //////////
     // Page //
     //////////
     $this->layout->page = view('errors.404');
     $this->layout->page->webconfig = $webconfig;
     $this->layout->title = 'Capcus.id';
     return $this->layout;
 }