當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Post::getSortFunctionNames方法代碼示例

本文整理匯總了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;
 }
開發者ID:jasonjyu,項目名稱:cscie15-p4,代碼行數:38,代碼來源:SearchController.php

示例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;
 }
開發者ID:jasonjyu,項目名稱:cscie15-p4,代碼行數:12,代碼來源:PostController.php


注:本文中的app\Post::getSortFunctionNames方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。