当前位置: 首页>>代码示例>>PHP>>正文


PHP Country::insertGetId方法代码示例

本文整理汇总了PHP中app\Country::insertGetId方法的典型用法代码示例。如果您正苦于以下问题:PHP Country::insertGetId方法的具体用法?PHP Country::insertGetId怎么用?PHP Country::insertGetId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\Country的用法示例。


在下文中一共展示了Country::insertGetId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: hash

 public function hash(Request $request, $key)
 {
     $link = DB::table('keys')->where('key', '=', $key)->get();
     if ($link) {
         $current_ip = $request->getClientIp();
         $test = app('Illuminate\\Routing\\UrlGenerator')->previous();
         // $name = $this->get_title($test);
         $name = 'google.com';
         $location = GeoIPFacade::getLocation('202.142.69.126');
         $os_info = parser::detect();
         //City data
         if (!City::where('city_name', $location['city'])->count()) {
             $city = new City();
             $city_id = $city->insertGetId(['city_name' => $location['city']]);
         } else {
             $city_id = City::where('city_name', $location['city'])->value('id');
         }
         //Country Data
         if (!Country::where('country_name', $location['country'])->count()) {
             $country = new Country();
             $country_id = $country->insertGetId(['country_name' => $location['country']]);
         } else {
             $country_id = Country::where('country_name', $location['country'])->value('id');
         }
         //Os Data
         if (!Operating_system::where('operating_system', $os_info['osFamily'])->count()) {
             $os = new Operating_system();
             $os_id = $os->insertGetId(['operating_system' => $os_info['osFamily']]);
         } else {
             $os_id = Operating_system::where('operating_system', $os_info['osFamily'])->value('id');
         }
         //Browser_data
         if (!Browser::where('browser_name', $os_info['browserFamily'])->count()) {
             $browser = new Browser();
             $browser_id = $browser->insertGetId(['browser_name' => $os_info['browserFamily']]);
         } else {
             $browser_id = Browser::where('browser_name', $os_info['browserFamily'])->value('id');
         }
         //Redirected Website data
         $website_hits = new Redirected_websites();
         $website_hits->user_id = $link[0]->user_id;
         $website_hits->url_id = $link[0]->id;
         $website_hits->city_id = $city_id;
         $website_hits->country_id = $country_id;
         $website_hits->website_url = $test;
         $website_hits->website_name = $name;
         $website_hits->browser_id = $browser_id;
         $website_hits->os_id = $os_id;
         $website_hits->is_mobile = $os_info['isMobile'];
         $website_hits->is_tablet = $os_info['isTablet'];
         $website_hits->is_desktop = $os_info['isDesktop'];
         //Hits data
         $data = new Hit();
         $data->url_ip = $current_ip;
         $data->url_id = $link[0]->id;
         $data->save();
         $website_hits->save();
         //Deep linking
         if (parser::isMobile()) {
             if (parser::osFamily() == 'Apple iOS') {
                 //link for apple store
             } elseif (parser::osFamily() == 'Windows') {
                 return redirect('https://www.microsoft.com/en-us/store/apps/google/9wzdncrfhx3w');
             } elseif (parser::osFamily() == 'Blackberry') {
                 //link for blackberry store
             } elseif (parser::osFamily() == 'AndroidOS') {
                 return redirect('https://play.google.com/store/apps/details?id=com.facebook.katana&hl=en');
             }
         }
         if (parser::isMobile()) {
             if (parser::osFamily() == 'Apple iOS') {
                 //link for apple store
             } elseif (parser::osFamily() == 'Windows') {
                 return redirect('https://www.microsoft.com/en-us/store/apps/google/9wzdncrfhx3w');
             } elseif (parser::osFamily() == 'Blackberry') {
                 //link for blackberry store
             } elseif (parser::osFamily() == 'AndroidOS') {
                 return redirect('https://play.google.com/store/apps/details?id=com.facebook.katana&hl=en');
             }
         } else {
             return redirect($link[0]->url);
         }
     } else {
         return redirect('/');
     }
 }
开发者ID:vikashkrkashyap,项目名称:url,代码行数:86,代码来源:UrlController.php


注:本文中的app\Country::insertGetId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。