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