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


PHP HomeController::previewFirstSimbol方法代码示例

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


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

示例1: getPage

 public function getPage($type, $slug = '')
 {
     $type_post = Type::where('type', $type)->first();
     $posts_child = $galleries = $posts = $row = array();
     if (empty($type_post)) {
         return Response::view('errors.not-found')->header('Content-Type', '404 Not Found');
     }
     if ($type_post->template == 'gallery') {
         $row = Post::where('slug', $type)->first();
         $type_post = Type::where('id', $row->type_id)->first();
         $galleries = Gallery::where('post_id', $row->id)->get();
     } else {
         if ($type_post->template == 'news') {
             if ($slug == '') {
                 $posts = Post::where('type_id', $type_post->id)->where('status', 1)->where('parent', 0)->orderBy('created_at', 'desc')->paginate(6);
             } else {
                 $row = Post::where('slug', $slug)->first();
             }
             foreach ($posts as $key => $post) {
                 $preview = HomeController::previewFirstSimbol($post->text, 500);
                 $post->preview = $preview['text'];
             }
         } else {
             if ($type_post->template == 'portfolio') {
                 $posts = Post::where('type_id', $type_post->id)->where('status', 1)->where('parent', 0)->orderBy('order', 'asc')->get();
                 foreach ($posts as $key => $post) {
                     $post->galleries = Gallery::where('post_id', $post->id)->get();
                 }
             } else {
                 $posts = Post::where('type_id', $type_post->id)->where('status', 1)->where('parent', 0)->orderBy('order', 'asc')->get();
                 $posts_child = Post::where('type_id', $type_post->id)->where('status', 1)->where('parent', '!=', 0)->orderBy('order', 'asc')->get();
                 if ($slug != '') {
                     $row = Post::where('slug', $slug)->first();
                     if ($row->parent != 0) {
                         $parent = Post::where('id', $row->parent)->first();
                         $row->parent_title = $parent->name;
                         $row->parent_slug = $parent->slug;
                     }
                     $galleries = Gallery::where('post_id', $row->id)->get();
                 }
             }
         }
     }
     $view = array('type' => $type_post, 'posts' => $posts, 'posts_child' => $posts_child, 'row' => $row, 'galleries' => $galleries);
     return View::make('home.' . $type_post->template, $view);
 }
开发者ID:ldin,项目名称:portfolio,代码行数:46,代码来源:HomeController.php


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