コード例 #1
0
ファイル: routes.php プロジェクト: hungnt88/5stars-1
    if (preg_match('/tag-([a-z0-9\-]+)/', $tag, $matches)) {
        $css = 'search';
        $page = null;
        $pageSearch = true;
        $term = $matches[1];
        if (strlen($term) > 2) {
            $term = str_replace('-',' ', $term);
            $keyword = Keyword::where('name', $term)->first();
            if (!$keyword) {
                $keyword = new Keyword();
                $keyword->create(['name' => $term, 'count' => 1]);
            } else {
                $keyword->count ++;
                $keyword->save();
            }
            $games = Game::tagged($term)->latest('update')->paginate(20);
        } else {
            $games = Game::latest('update')->paginate(20);
        }
        return view('games.search', compact('games', 'term', 'pageSearch', 'css', 'page'))->with([
            'title' => 'Search result for '.$term.' - AppForAndroidPhone',
            'desc' => '',
            'keyword' => ''
        ]);
    }
});

//categories details

Route::get('android/{value}', function($value){
    if (preg_match('/top-([a-z0-9\-]+)-(apps|games)/', $value, $matches)) {
コード例 #2
0
ファイル: MainController.php プロジェクト: hungnt88/5stars-1
 /**
  * http request from javascript
  * @param Request $request
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function suggestion(Request $request)
 {
     $games = Game::tagged($request->input('term'))->latest('update')->take(10)->get();
     return response()->json($games);
 }