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


PHP Category::getCategoryById方法代码示例

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


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

示例1: getTopicOptions

 /**
  * @return array
  */
 public function getTopicOptions()
 {
     $raw = Topic::find()->orderBy('Category_id')->all();
     $arr = array();
     foreach ($raw as $row) {
         $categpry = \app\models\Category::getCategoryById($row['Category_id']);
         $arr[$row['id']] = $categpry . ' - ' . $row['name'];
     }
     return $arr;
 }
开发者ID:pyw5pkU9PcdW,项目名称:COMP3421,代码行数:13,代码来源:Topic.php

示例2: export

 public function export()
 {
     $data = array(array('Name', 'Alias', 'Meta keywords', 'Meta description', 'Parent', 'Publish', 'Views', 'Type'));
     $pages = Category::getCategoriesByContentType(2);
     foreach ($pages as $page) {
         $page_array = array();
         $name = $page['name'];
         array_push($page_array, $name);
         $alias = $page['alias'];
         array_push($page_array, $alias);
         if (empty($page['meta_keys'])) {
             $meta_keys = 'None';
         } else {
             $meta_keys = $page['meta_keys'];
         }
         array_push($page_array, $meta_keys);
         if (empty($page['meta_desc'])) {
             $meta_desc = 'None';
         } else {
             $meta_desc = $page['meta_desc'];
         }
         array_push($page_array, $meta_desc);
         if ($page['type'] == 1) {
             $parent = 'None';
         } else {
             $parent = Category::getCategoryById($page['parent_id'])['name'];
         }
         array_push($page_array, $parent);
         if ($page['publish'] == 1) {
             $publish = 'Published';
         } else {
             $publish = 'Unpublished';
         }
         array_push($page_array, $publish);
         $views = (string) $page->visits()->count();
         array_push($page_array, $views);
         if ($page['type'] == 1) {
             $type = 'Parent';
         } else {
             $type = 'Sub category';
         }
         array_push($page_array, $type);
         array_push($data, $page_array);
     }
     Excel::create('Pages', function ($excel) use($data) {
         $excel->sheet('Pages', function ($sheet) use($data) {
             $sheet->fromArray($data, null, 'A1', false, false);
             $sheet->cells('A1:H1', function ($cells) {
                 $cells->setFontWeight('bold');
             });
         });
     })->export('xls');
 }
开发者ID:GHarutyunyan,项目名称:cms,代码行数:53,代码来源:PageController.php

示例3: export

 /**
  * Export posts
  */
 public function export()
 {
     $data = array(array('Name', 'Alias', 'Tags', 'Category', 'Status', 'Views', 'Publish'));
     $posts = Post::getPosts(0, '', Auth::user()->id);
     foreach ($posts as $post) {
         $post_array = array();
         $alias = $post['alias'];
         array_push($post_array, $alias);
         if ($post->tags->count() == 0) {
             $tags = 'None';
         } else {
             $tags = "";
             foreach ($post->tags as $tag) {
                 $tags .= $tag['name'] . ',';
             }
         }
         array_push($post_array, $tags);
         if (empty($post['category_id'])) {
             $category = 'None';
         } else {
             $category = Category::getCategoryById($post['category_id'])['name'];
         }
         array_push($post_array, $category);
         if ($post['approve'] == 1) {
             $status = 'Approved';
         } else {
             $status = 'Not approved';
         }
         array_push($post_array, $status);
         $visits = (string) $post->visits()->count();
         array_push($post_array, $visits);
         if (empty($post['publish'])) {
             $publish = 'Unpublished';
         } else {
             $publish = 'Published';
         }
         array_push($post_array, $publish);
         array_push($data, $post_array);
     }
     Excel::create('Posts', function ($excel) use($data) {
         $excel->sheet('Posts', function ($sheet) use($data) {
             $sheet->fromArray($data, null, 'A1', false, false);
             $sheet->cells('A1:G1', function ($cells) {
                 $cells->setFontWeight('bold');
             });
         });
     })->export('xls');
 }
开发者ID:GHarutyunyan,项目名称:cms,代码行数:51,代码来源:PostController.php


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