示例#1
0
 /**
  * Store a newly created resource in storage.
  */
 public function store()
 {
     if (\Input::has('q')) {
         $q = trim(\Input::get('q'));
         if (!empty($q)) {
             $search = \Veer\Models\Search::firstOrCreate(array("q" => $q));
             $search->increment('times');
             $search->save();
             if (auth_check_session()) {
                 $search->users()->attach(\Auth::id());
             }
             return $this->results($this->showSearch->getSearchResultsWithSite(app('veer')->siteId, $q, get_paginator_and_sorting()));
         }
     }
     return $this->index();
 }
示例#2
0
 public function add($q, $users_id = null, $returnId = false)
 {
     $search = \Veer\Models\Search::firstOrCreate(["q" => $q]);
     $search->increment('times');
     $search->save();
     if (!empty($users_id)) {
         if (!is_array($users_id)) {
             $users_id = explode(',', trim($users_id, ': '));
         }
         if ($users_id) {
             $search->users()->attach($users_id);
             event('veer.message.center', trans('veeradmin.search.new'));
         }
     }
     return $returnId ? $search->id : $this;
 }