Esempio n. 1
0
 /**
  * Быстрый поиск
  * @param  Search $search
  * @param  Request $request
  * @return \Illuminate\Http\JsonResponse
  */
 public function searchApi(Search $search, Request $request)
 {
     $workers = $search->searchWorkers($request->q, 10);
     // Смотрим, есть ли для этого работника файлы недвижимости, авто или предпринимательства. Плюсуем их к notes_count
     $resultworkers = $workers->toArray();
     for ($i = 0; $i < count($resultworkers); $i++) {
         $resultworkers[$i]['notes_count'] += get_additional_notes_count($resultworkers[$i]['fio']);
     }
     return response()->json(['organizations' => $search->searchOrganizations($request->q, 10), 'workers' => $resultworkers]);
 }
Esempio n. 2
0
 public function postStockProductResult()
 {
     $branch = Input::get('branch_id');
     $stock = Input::get('stock_info_id');
     $category = Input::get('category_id');
     $product = Input::get('product_id');
     $date1 = Input::get('from_date');
     $date2 = Input::get('to_date');
     $search = new Search();
     $results = $search->getResultStockProducts($category, $product, $date1, $date2, $branch, $stock);
     return view('Searches.stockProductResult', compact('results'));
 }
 public function retrieveSearch($id, Search $search)
 {
     $result = $search->getSearch($id);
     if ($result instanceof Illuminate\Database\Eloquent\ModelNotFoundException) {
         return view('compare-form')->with('message', 'Could not find that listing. It may have been deleted');
     } else {
         $leeds = json_decode($result->leeds);
         $london = json_decode($result->london);
         $searchresult = $result->id;
         $result->sale_or_rent == 'rent' ? $rent = true : ($rent = false);
         return view('compare-results', compact('leeds', 'london', 'searchresult', 'rent'));
     }
 }
Esempio n. 4
0
 /**
  * Execute the command.
  *
  * @return void
  */
 public function handle()
 {
     $term = \App\Term::firstOrCreate(['q' => $this->q]);
     $term->increment('searches_count');
     $this->data['term_id'] = $term->id;
     \App\Search::firstOrCreate($this->data)->increment('count');
 }
 public static function searchLocationTweets($locName, $locLat, $locLng)
 {
     $location = Location::where('latitude', '=', round($locLat, 7))->where('longitude', '=', round($locLng, 7))->first();
     $tweets = null;
     if ($location == null) {
         $location = new Location();
         $location->name = $locName;
         $location->latitude = round($locLat, 7);
         $location->longitude = round($locLng, 7);
         $locRet = $location->save();
         //save search history
         $search = new Search();
         $search->location_id = $location->id;
         $search->user = $_COOKIE['user'];
         $search->save();
         $tweets = self::getTweets($locName, round($locLat, 7), round($locLng, 7));
         //save tweets
         foreach ($tweets as $tweet) {
             $tweet->search_id = $search->id;
             $tweet->save();
         }
     } else {
         $search = Search::where('location_id', '=', $location->id)->orderBy('created_at', 'desc')->first();
         $searchTime = strtotime($search->created_at);
         //save new search
         $newSearch = new Search();
         $newSearch->location_id = $location->id;
         $newSearch->user = $_COOKIE['user'];
         $newSearch->save();
         //if search is older than 1 hour, tweet again
         if ($searchTime <= strtotime('-' . Config::get('app.cache_duration') . ' minutes')) {
             $tweets = self::getTweets($locName, round($locLat, 7), round($locLng, 7));
             //save tweets
             foreach ($tweets as $tweet) {
                 $tweet->search_id = $search->id;
                 $tweet->save();
             }
         } else {
             //get last search with tweets
             $search = DB::table('searches')->where('location_id', '=', $location->id)->whereExists(function ($query) {
                 $query->select(DB::raw(1))->from('tweets')->whereRaw('tweets.search_id = searches.id');
             })->orderBy('created_at', 'desc')->first();
             $tweets = Tweet::where('search_id', '=', $search->id)->get();
         }
     }
     return $tweets;
 }
Esempio n. 6
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $this->search = Search::find($this->argument('search_id'));
     if ($this->search === null) {
         return false;
     }
     return $this->crawler->run($this->search);
 }
Esempio n. 7
0
 public function findDomain(Request $request)
 {
     $user = $request->user();
     $inputs = $request->only('q');
     $domains = Domain::where('domain', 'LIKE', '%' . $inputs['q'] . '%')->get();
     $search = new Search();
     $search->query = $inputs['q'];
     $search->user_id = $user->id;
     $search->save();
     foreach ($domains as $domain) {
         $result = new Searches_has_domain();
         $result->searches_id = $search->id;
         $result->domains_id = $domain->id;
         $result->save();
     }
     return response()->json($domains);
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $searchData = Search::select("*")->join('status_types', 'status_types.id', '=', 'searches.status_id')->where('searches.id', '=', $id)->get();
     $searchData[0]['date_of_birth'] = $this->formatDate($searchData[0]['date_of_birth']);
     $searchData[0]['start_travel'] = $this->formatDate($searchData[0]['start_travel']);
     $searchData[0]['end_travel'] = $this->formatDate($searchData[0]['end_travel']);
     $searchData[0]['created_at'] = $this->formatDate($searchData[0]['created_at'], 1);
     return \Response::json($searchData);
 }
Esempio n. 9
0
 public function delete($value)
 {
     // formating hours on date
     $date = new \DateTime(strtotime(time()));
     $date = $date->modify('-' . $value . 'hours')->format('Y-m-d H:i:s');
     // deleting rows by doctrine with cascade delete entity settings in db schema
     $qb = $this->em->createQueryBuilder();
     $q = $qb->delete(Search::getClassName(), 's')->where($qb->expr()->lt('s.date', '?1'))->setParameter(1, $date)->getQuery();
     return $numberDeleted = $q->getResult();
 }
Esempio n. 10
0
 public function search()
 {
     $query = Request::get('q');
     if ($query) {
         $search = Search::where('foodName', 'LIKE', "%{$query}%")->get();
     } else {
         $search = Search::get();
     }
     return view('search')->with('search', $search);
 }
Esempio n. 11
0
 public function renderDefault($id)
 {
     if (!is_null($id)) {
         $search = $this->em->find(Search::getClassName(), $id);
         if (!$search) {
             $this->flashMessage('Data not found for this id', 'error');
             $this->redirect('Homepage:');
         }
     } else {
         $this->flashMessage('Data not found for this id', 'error');
     }
     $this->template->search = $search;
 }
Esempio n. 12
0
 public function renderDefault($page)
 {
     // initial dao object
     $dao = $this->em->getRepository(Search::getClassName());
     $searchQuery = new SearchQuery();
     // initial paginator
     $paginator = new Nette\Utils\Paginator();
     $paginator->setPage($page);
     $searchs = $dao->fetch($searchQuery)->applySorting(array('Search.date' => 'DESC'))->applyPaginator($paginator, self::ROWSONPAGE);
     $numberRows = $searchs->getTotalCount();
     $paginator->setItemCount($numberRows);
     // push data to template
     $this->template->search = $searchs;
     $this->template->paginator = $paginator;
     $this->template->page = $page;
 }
Esempio n. 13
0
 /**
  * Show the application dashboard.
  *
  * @return \Illuminate\Http\Response
  */
 public function index(Request $request)
 {
     $user = $request->user();
     return view('home', ['last_searches' => Search::where('user_id', $user->id)->orderBy('created_at')->limit(3)->get()]);
 }
Esempio n. 14
0
 /**
  * Handle the event.
  *
  * @param  VoidSearch  $event
  * @return void
  */
 public function handle(VoidSearch $event)
 {
     //
     Search::create(['user_id' => $event->user->id, 'keyword' => $event->keyword]);
 }
Esempio n. 15
0
 /**
  * Give the user a file containing all the search resources.
  *
  * @param int $searchId
  * @return \Illuminate\Http\RedirectResponse|\Symfony\Component\HttpFoundation\BinaryFileResponse
  */
 public function download($searchId)
 {
     $resources = Search::find($searchId)->resources()->get()->lists('name')->unique()->toArray();
     return $this->respondWithFile($resources);
 }
Esempio n. 16
0
 public function voidsearch()
 {
     $searches = Search::with('user', 'user.area')->get();
     return view('admin.globals.voidsearch', compact('searches'));
 }
Esempio n. 17
0
 /**
  * Get the search's url that has not been crawled yet.
  *
  * @return mixed
  */
 protected function getNextNotCrawledUrl()
 {
     return $this->search->urls()->where('crawled', '0')->first();
 }
Esempio n. 18
0
 public function saveData($searchString)
 {
     // get IP and actual Date
     $ip = $this->request->getRemoteAddress();
     // get datetime
     $date = new \DateTime();
     // new gneral entity
     $search = new Search();
     $search->setSearch($searchString);
     $search->setDate($date);
     $search->setIp($ip);
     $this->em->persist($search);
     return $search;
 }