You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
833 B

  1. <?php
  2. namespace App\Jobs;
  3. use Log;
  4. use App\Jobs\Job;
  5. use Illuminate\Contracts\Bus\SelfHandling;
  6. use Illuminate\Contracts\Queue\ShouldQueue;
  7. use DateTime, DateTimeZone;
  8. class NotifyOfNewLocations extends Job implements SelfHandling, ShouldQueue
  9. {
  10. private $_dbid;
  11. public function __construct($dbid, $data) {
  12. $this->_dbid = $dbid;
  13. }
  14. public function handle() {
  15. $db = DB::table('databases')->where('id','=',$this->_dbid)->first();
  16. $urls = preg_split('/\s+/', $db->ping_urls);
  17. foreach($urls as $url) {
  18. $ch = curl_init($url);
  19. curl_setopt($ch, CURLOPT_POST, true);
  20. curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query([
  21. 'url' => env('BASE_URL').'api/last?token='.$db->token.'&geocode=1'
  22. ]));
  23. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  24. curl_exec($ch);
  25. }
  26. }
  27. }