コード例 #1
0
ファイル: Filter.php プロジェクト: stels-cs/tinder-olega
 public function store(\Illuminate\Http\Request $r)
 {
     try {
         $filter = $r->get('filter', []);
         if (!empty($filter)) {
             $hash = VKFilter::createHash($filter);
             $_filter = VKFilter::where('hash', $hash)->where('user_id', $this->getUser()->id)->first();
             if (empty($_filter)) {
                 $_filter = VKFilter::create(['filter' => $filter, 'user_id' => $this->getUser()->id]);
                 $data = $_filter->fastParse($this->getUser());
                 $this->startFetchingFilter($_filter);
                 if ($data->count() < 2) {
                     $_filter->attachFromLoad(false, true);
                     $data = $filter->getList();
                 }
                 return response()->json(['filter' => $_filter, 'feed' => $data]);
             } else {
                 return response()->json(['filter' => $_filter, 'feed' => $_filter->getList($this->getUser())]);
             }
         } else {
             return response()->json(['filter' => trans('main.filter-empty')], 400);
         }
     } catch (\Exception $e) {
         \Log::error($e->getMessage() . ' ' . $e->getFile() . ':' . $e->getLine());
         return $e->getMessage() . ' file ' . $e->getFile() . ':' . $e->getLine();
     }
 }
コード例 #2
0
ファイル: Info.php プロジェクト: stels-cs/tinder-olega
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $u = $this->argument('u');
     $okCount = VKUsers::where('fake', false)->count();
     $this->info('good akk in db = ' . $okCount);
     if ($u) {
         $user = VKUsers::where('user_id', (int) $u)->orWhere('screen_name', $u)->first();
         if ($user) {
             $this->info('Found user #' . $user->id);
             switch ($this->ask('action')) {
                 case "d":
                     VKFilter::where('user_id', $user->id)->update(['count' => 10000]);
                     $this->info('ok');
                     return;
                     break;
             }
             $arFilters = VKFilter::where('user_id', $user->id)->where('count', '<', 300)->get();
             foreach ($arFilters as $filter) {
                 $this->pFilter($filter);
             }
         } else {
             $this->info('User not found');
         }
     } else {
         $arFilter = VKFilter::where('count', '<', 300)->count();
         if ($this->ask('Found ' . $arFilter . ' show all?') == 'y') {
             foreach (VKFilter::where('count', '<', 300)->get() as $filter) {
                 $this->pFilter($filter);
             }
         }
     }
 }