本文整理汇总了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);
}
示例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);
}