本文整理匯總了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);
}