/**
  * 
  * @return type
  */
 public function saveUrls(ScraperInterface $scrapper)
 {
     $keyword = Request::input('keyword');
     if ($keyword == '') {
         return Response::json(array('success' => false, 'error' => 'Please enter a keyword'), 400);
     }
     $links = $scrapper->getUrls($keyword);
     if (count($links) === 0) {
         return Response::json(array('success' => false, 'error' => 'There were no urls found...'), 400);
     }
     $k = Keyword::where('value', '=', $keyword)->first();
     if ($k === null) {
         $keywordValidator = Validator::make(['value' => $keyword], ['value' => 'required|unique:keywords']);
         if (!$keywordValidator->fails()) {
             $k = Keyword::create(['value' => $keyword]);
         } else {
             return Response::json(array('success' => false, 'error' => 'Error has occurred...'), 400);
         }
     }
     foreach ($links as $link) {
         $LinkValidator = Validator::make(['keyword_id' => $k->id, 'rank' => $link['rank'], 'value' => $link['value']], ['keyword_id' => 'required|numeric', 'rank' => 'required|numeric', 'value' => 'required|url']);
         if (!$LinkValidator->fails()) {
             Link::create(array('keyword_id' => $k->id, 'rank' => $link['rank'], 'value' => $link['value']));
         }
     }
     return Response::json(array('success' => true));
 }
 public function create(array $data)
 {
     //return $data;
     return Keyword::create(['keyword_rule_id' => $data['keyword_rule_id'], 'keyword' => $data['keyword'], 'match_type' => $data['match_type']]);
 }
Example #3
0
        'desc' => '',
        'keyword' => ''
    ]);
});
Route::get('search/{tag}', function($tag) {
    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' => ''
        ]);
    }
});