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


PHP Ad::groupBy方法代码示例

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


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

示例1: getIndex

 public function getIndex($slug = '', $link_id = 0)
 {
     $debug = '';
     $bmStart = microtime(true);
     $perpage = intval(AppConfig::get('articles_per_page', 50));
     $branch_prefixes = explode(',', AppConfig::get('branch_prefixes'));
     $virtualPerpage = intval(AppConfig::get('virtual_per_page', 20));
     $page = Page::where('slug', '=', $slug)->cacheTags('pages')->remember(1440)->first();
     //$page = Page::where('slug', '=', Str::slug($slug))->first();
     if (count($page) > 0) {
         if ($filter_return = $this->authFilter($page->level)) {
             return $filter_return;
         }
         if ($page->redirect) {
             if (substr($page->redirect, 0, 1) == '{') {
                 $redir_arr = json_decode($page->redirect, true);
                 foreach ($redir_arr as $rlvl => $rslug) {
                     if (strpos($this->auth_lvl, $rlvl) !== false) {
                         return Redirect::to($rslug);
                     }
                 }
                 if (isset($redir_arr['def'])) {
                     return Redirect::to($redir_arr['def']);
                 }
             } else {
                 return Redirect::to($page->redirect);
             }
         }
         // get parameters from URL
         $page->category = Input::has('category') ? Input::get('category') : ($page->default_category ? $page->default_category : false);
         $page->section = Input::has('section') ? Input::get('section') : false;
         $page->keywordInput = $page->ddkeycol ? Input::get('keyword') : '';
         $page_vars = new stdClass();
         // separate slug into branch and section, if applicable
         $branch = $slug;
         if ($page->link_slug) {
             $branch = $page->link_slug;
         }
         $els = explode('/', $branch);
         if (in_array($els[0], $branch_prefixes) && count($els) > 1) {
             $branch = $els[0];
             if (!$page->section) {
                 $page->section = $els[1];
             }
         }
         $dta = normal::getTypes();
         // get list of categories, if there is a "ddlist"
         $categories = false;
         $normalized = false;
         if ($page->ddlist) {
             $fld = $page->ddlist;
             $catq = Link::where('branch', '=', $branch);
             if ($page->section) {
                 $catq->where('section', '=', $page->section);
             }
             if ($dtp = array_search($fld, $dta)) {
                 $catq->join('data', 'data.rec_id', '=', 'links.id')->where('data.table_name', '=', 'links')->where('data.type', '=', $dtp)->whereNull('data.deleted_at');
                 $fld = 'data_body';
                 $normalized = true;
             }
             $category_model = $catq->groupBy($fld)->whereRaw('trim(`' . $fld . '`) != ""')->cacheTags('links')->remember(1440)->get(array($fld));
             $categories = array('' => 'All');
             foreach ($category_model as $category_item) {
                 $categories[$category_item->{$fld}] = $category_item->{$fld};
             }
         }
         $links = false;
         $columns = false;
         // get list of links, specified by branch, section, category, state, and/or keyword
         if ($page->linkdef || $link_id && $page->detaildef) {
             // get column layout
             $columns = Listcolumns::where('def', '=', $link_id ? $page->detaildef : $page->linkdef)->cacheTags('links')->remember(1440)->orderBy('listorder')->get();
             $perlinkpage = intval(AppConfig::get('links_per_page', 50));
             $query = new Link();
             if ($link_id) {
                 $query = $query->where('id', '=', $link_id);
             } else {
                 if ($page->section) {
                     $query = $query->where('section', '=', $page->section);
                 }
                 if ($page->category) {
                     if ($normalized) {
                         $query = $query->join('data AS d', 'd.rec_id', '=', 'links.id')->where('d.table_name', '=', 'links')->where('d.type', '=', $dtp)->whereNull('d.deleted_at');
                     }
                     $query = $query->where(isset($fld) ? $fld : ($page->section ? 'category' : 'section'), '=', $page->category);
                 }
                 if ($page->state) {
                     $query = $query->where('state', '=', $page->state);
                 }
                 if ($page->keywordInput) {
                     if ($page->keywordInput == "by_date") {
                         $query = $query->join('data AS d', 'd.rec_id', '=', 'links.id')->where('d.table_name', '=', 'links')->where('d.type', '=', 7)->whereNull('d.deleted_at');
                         $month = Input::get('themonth');
                         $year = Input::get('theyear');
                         $pfx = $year . '-' . $month;
                         $start_date = $pfx . '-01';
                         $end_date = $pfx . '-' . cal_days_in_month(CAL_GREGORIAN, $month, $year);
                         $query = $query->whereRaw('d.`data_body`  BETWEEN ? AND ?', array($start_date, $end_date));
                         unset($page->keywordInput);
                         $page_vars->month = $month;
//.........这里部分代码省略.........
开发者ID:ke6scs,项目名称:samples,代码行数:101,代码来源:PageController.php


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