Ejemplo n.º 1
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $all = $this->argument('all') === 'true';
     if ($all) {
         $voters = Voter::all();
     } else {
         $voters = Voter::whereNull('polling_station_id')->take($this->argument('take'))->get();
     }
     $this->output->progressStart(count($voters));
     Log::info('Inicio de Actualización de puestos de votación');
     foreach ($voters as $voter) {
         $result = $voter->hasPollingStation($all);
         if ($result['status']) {
             $pollingStation = $result['polling_station'];
             $voter->polling_station_id = $pollingStation->id;
             $voter->table_number = $result['table_number'];
             $voter->save();
             Log::info('Votante CC: ' . $voter->doc . ' - ' . $voter->name . ' actualizado puesto de votación ' . $pollingStation->name);
         } else {
             Log::info('Votante CC: ' . $voter->doc . ' - ' . $voter->name . ' ' . $result['message']);
         }
         $this->output->progressAdvance();
     }
     $this->output->progressFinish();
     Log::info('FIN de Actualización de puestos de votación');
 }
Ejemplo n.º 2
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $voters = Voter::votersBirthDay();
     $now = date('m-d');
     list($mounthNow, $dayNow) = explode('-', $now);
     $numbers = [];
     foreach ($voters as $count => $voter) {
         $number = [];
         list($year, $mounth, $day) = explode('-', $voter->date_of_birth);
         if ($mounth == $mounthNow && $day == $dayNow) {
             $number['telephone'] = $voter->telephone;
             $number['message'] = $voter->happy_birthday;
             array_push($numbers, $number);
             $this->info('Mensaje por enviar a ' . $voter->telephone);
         }
     }
     $sendSMS = new SendSMS();
     $sendSMS->sendCustomMessages($numbers);
     Log::info('Mensajes de cumpleaños enviados. Cantidad: ' . count($numbers));
     $this->info('OK');
 }