本文整理汇总了PHP中app\Post::getSortFunctionNames方法的典型用法代码示例。如果您正苦于以下问题:PHP Post::getSortFunctionNames方法的具体用法?PHP Post::getSortFunctionNames怎么用?PHP Post::getSortFunctionNames使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Post
的用法示例。
在下文中一共展示了Post::getSortFunctionNames方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getIndex
/**
* Displays the Search results page.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function getIndex(Request $request)
{
// check if request query parameters array is empty
if (empty($request->all())) {
// if most recently searched hashtag term exists,
// then redirect to the search page for that term
// otherwise, return the default search page
$searched_term = \Session::get('searched_term');
if (isset($searched_term)) {
$view = redirect('/search?term=' . $searched_term);
} else {
$view = view('search.index');
}
} else {
// validate request
$this->validate($request, ['term' => 'required']);
// parse request
$term = strtolower(preg_replace('/\\s+/', '', $request->term));
// remove whitespace, convert to lowercase
// save off hashtag term
$this->saveHashtag($term);
// get the social media posts for the specified hashtag term
$posts = $this->getPosts($term);
// get all the base sort function names for posts
$posts_sort_by_names = Post::getSortFunctionNames();
// enable form for posts if a user is logged in
$posts_enable_form = \Auth::check();
// return the search results page
$view = view('search.index')->with(compact(['term', 'posts', 'posts_sort_by_names', 'posts_enable_form']));
}
return $view;
}
示例2: getDelete
/**
* Displays the Delete Posts page.
*
* @return \Illuminate\Http\Response
*/
public function getDelete()
{
// return the Delete Posts page with the user's saved posts and posts
// form enabled
$view = view('posts.delete')->with(['posts' => $this->getUserPosts(), 'posts_sort_by_names' => Post::getSortFunctionNames(true), 'posts_enable_form' => true]);
return $view;
}