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.

32 lines
839 B

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