/** * Execute the console command. * * @return mixed */ public function handle() { /* curl -u YOUR_SECRET_KEY: -H "Content-Type: application/json" -H "X-Ionic-Application-Id: YOUR_APP_ID" https://push.ionic.io/api/v1/push -d '{"tokens": ["YOUR_TOKEN"],"notification":{"alert":"Hello world."}}' */ $numbers = ContactRequest::all()->pluck('phone'); $alert = Alert::Create(['message' => $this->argument('message')]); /*$tokens = DeviceToken::all('token')->pluck('token'); \Log::info('Tokens', $tokens->toArray()); $fields = array ( "tokens"=> $tokens, "notification" => [ 'alert' => $this->argument('message')] ); $headers = array ( 'X-Ionic-Application-Id: 35509efc', 'Content-Type: application/json' ); $username='******'; $ch = curl_init(); curl_setopt( $ch,CURLOPT_URL, 'https://push.ionic.io/api/v1/push' ); curl_setopt( $ch,CURLOPT_POST, true ); curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers ); curl_setopt($ch, CURLOPT_USERPWD, "$username"); curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true ); curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, false ); curl_setopt( $ch,CURLOPT_POSTFIELDS, json_encode( $fields ) ); $result = curl_exec($ch ); curl_close( $ch ); echo $result;*/ foreach ($numbers as $number) { try { Mail::raw($this->argument('message'), function ($message) use($number) { $message->from('*****@*****.**'); $message->to($number); $message->subject('New Info!'); }); } catch (Exception $e) { break; } } }