HttpToHttps.php 663 B

1234567891011121314151617181920212223
  1. <?php
  2. namespace App\Casts;
  3. use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
  4. class HttpToHttps implements CastsAttributes
  5. {
  6. public function get($model, string $key, $value, array $attributes)
  7. {
  8. // 使用内网上传需要转换
  9. $value = str_replace('http://','https://',$value);
  10. $value = str_replace('-internal','',$value);
  11. return $value;
  12. }
  13. public function set($model, string $key, $value, array $attributes)
  14. {
  15. // 使用内网上传需要转换
  16. $value = str_replace('http://','https://',$value);
  17. $value = str_replace('-internal','',$value);
  18. return $value;
  19. }
  20. }