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


PHP Post::get_all_posts方法代码示例

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


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

示例1: index

 /**
  * Show the application dashboard to the user.
  * 
  * @return Response
  */
 public function index($category_id = 0)
 {
     $keyword = trim(Input::get('keyword'));
     $data['keyword'] = $keyword;
     if (Auth::check() && Auth::user()->hasRole('user')) {
         $category_id = trim($category_id);
         $url_image = LibraryPublic::get_url_image(Auth::user()->image);
         Session::put('url_image_auth', $url_image);
         $rules = ['keyword' => 'max:150|min:1'];
         $validator = Validator::make($data, $rules);
         if ($validator->fails()) {
             $data['keyword'] = "";
             $posts = Post::get_all_posts($category_id);
         } else {
             $posts = Post::get_all_posts($category_id, $keyword);
         }
         $data['posts'] = $posts;
         $data['categories'] = Category::all();
     }
     if (Auth::check() && Auth::user()->hasRole('admin')) {
         return redirect('admin');
     }
     return view('home', $data);
 }
开发者ID:ambarsetyawan,项目名称:laravel-1,代码行数:29,代码来源:HomeController.php

示例2: getView

 /**
  * View profile of other user function
  *
  * @author Tran Van Moi <[moitran92@gmail.com]>
  * @since 2015/05/12
  * @return Response
  */
 public function getView($user_id = null, $category_id = null)
 {
     $keyword = trim(Input::get('keyword'));
     $category_id = trim($category_id);
     $data = ['user_id' => $user_id];
     $rules = ['user_id' => 'required|exists:users,id'];
     $validator = Validator::make($data, $rules);
     if ($validator->fails()) {
         Session::flash('view_user_error', 'User is not found!');
     } else {
         if ($user_id == Auth::user()->id) {
             return redirect('user/profile');
         }
         $check_user_exist = User::whereDelete_status(0)->whereId($user_id)->first();
         if ($check_user_exist) {
             $data['keyword'] = $keyword;
             $rules = ['keyword' => 'max:150|min:1'];
             $validator = Validator::make($data, $rules);
             if ($validator->fails()) {
                 $data['keyword'] = "";
                 $data['posts'] = Post::get_all_posts($category_id, "", $user_id);
             } else {
                 $data['posts'] = Post::get_all_posts($category_id, $keyword, $user_id);
             }
             $data['categories'] = Category::all();
             if (filter_var($check_user_exist->image, FILTER_VALIDATE_URL) === false) {
                 $check_user_exist->image = URL::to('/') . "/public/images/avatar/" . $check_user_exist->image;
             }
             $data['user_info'] = $check_user_exist;
             $data['total_like'] = Like::total_like_user($user_id);
         } else {
             Session::flash('view_user_error', 'User is not found!');
         }
     }
     return view('user/view', $data);
 }
开发者ID:ambarsetyawan,项目名称:laravel-1,代码行数:43,代码来源:UserController.php


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