ImageFile.php 658 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace Illuminate\Validation\Rules;
  3. class ImageFile extends File
  4. {
  5. /**
  6. * Create a new image file rule instance.
  7. *
  8. * @param bool $allowSvg
  9. */
  10. public function __construct($allowSvg = false)
  11. {
  12. if ($allowSvg) {
  13. $this->rules('image:allow_svg');
  14. } else {
  15. $this->rules('image');
  16. }
  17. }
  18. /**
  19. * The dimension constraints for the uploaded file.
  20. *
  21. * @param \Illuminate\Validation\Rules\Dimensions $dimensions
  22. * @return $this
  23. */
  24. public function dimensions($dimensions)
  25. {
  26. $this->rules($dimensions);
  27. return $this;
  28. }
  29. }