Ejemplo n.º 1
0
 public function view(Request $request)
 {
     if (!$request->date) {
         abort(500, 'Запрос неверный');
     }
     $contract_ids = UserSendedContract::where('user_id', Auth::user()->id)->whereBetween('created_at', [$request->date . ' 00:00:00', $request->date . ' 23:59:59'])->lists('contract_id');
     $list = Contract::whereIn('id', $contract_ids)->with('organization')->get();
     return view('admin.contracts.view', compact('list'));
 }
Ejemplo n.º 2
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $elastic = ClientBuilder::create()->build();
     $searches = ContractSearchCriteria::with('user')->get();
     foreach ($searches as $search) {
         $criteria = json_decode($search->criterias, true);
         $this->info('Обработка критерия для пользователя ' . $search->user_id);
         if (is_array($criteria) && sizeof($criteria) > 0) {
             $max_id = (int) UserSendedContract::where('user_id', $search->user_id)->max('contract_id');
             $this->info('Поиск контрактов');
             $contract_ids = Contract::elasticSearch($search, $max_id);
             foreach ($contract_ids as $contract) {
                 UserSendedContract::create(['user_id' => $search->user_id, 'contract_id' => $contract]);
             }
             $list = Contract::whereIn('id', $contract_ids)->with('organization')->get();
             Mail::send('emails.contracts', ['list' => $list], function ($m) use($list, $search, $contract_ids) {
                 $m->from('*****@*****.**', 'infotendermail');
                 $m->to($search->user->email, $search->user->name)->subject('Контракты с infotendermail.ru #' . sizeof($contract_ids));
             });
         }
     }
 }