コード例 #1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $request->name = strtolower($request->name);
     $this->validate($request, ['name' => 'required|unique:keywords|max:255', 'category' => 'required']);
     $category = Category::findOrFail($request->category);
     $tag = new Keyword();
     $tag->name = $request->name;
     $tag->category()->associate($category);
     $tag->save();
     return Redirect::route('admin.tags.index');
 }
コード例 #2
0
ファイル: CampainController.php プロジェクト: patualeja/TESIS
 public function processAdvert($campain_id)
 {
     $userName = Auth::user()->name;
     $campain = Campain::find($campain_id);
     $advert = $campain->advert;
     $response = "";
     try {
         $ml = new MonkeyLearn\Client('74312b126c6fcee32bddc68b6b3d4b15fee48868');
         $text_list = [$advert];
         $module_id = 'ex_eV2dppYE';
         $res = $ml->extractors->extract($module_id, $text_list);
         $results = $res->result;
         $response = $results[0];
     } catch (Exception $e) {
         echo 'Message: ' . $e->getMessage();
     }
     $colors = ['bg-success', 'bg-primary', 'bg-danger', 'bg-warning'];
     $keywords = [];
     foreach ($response as $item) {
         $text = $item["keyword"];
         $relevance = $item["relevance"];
         $isRegistered = 'Existente';
         $color = $colors[array_rand($colors)];
         $relevance = $relevance * 100 . "%";
         $keyword = Keyword::where('text', '=', $text)->get();
         if (count($keyword) == 0) {
             $isRegistered = 'Nuevo Registro';
             $keyword = new Keyword();
             $keyword->text = $text;
             $keyword->save();
         } else {
             $keyword = $keyword[0];
         }
         $link = new Link();
         $link->campain_id = $campain_id;
         $link->keyword_id = $keyword->id;
         $link->save();
         $keywords[] = ["text" => $text, "relevance" => $relevance, "isRegistered" => $isRegistered, "color" => $color];
     }
     return view('campain.result', ['userName' => $userName, 'textArticle' => $advert, 'keywords' => $keywords]);
 }
コード例 #3
0
ファイル: routes.php プロジェクト: hungnt88/5stars-1
});
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' => ''
        ]);
    }
});

//categories details