Drug.php 596 B

123456789101112131415161718192021222324252627
  1. <?php
  2. namespace App\Model;
  3. class Drug extends ModelAbstract
  4. {
  5. public $id;
  6. public $name;
  7. public $group;
  8. public function __construct(string $name, string $group, int $id = null)
  9. {
  10. $this->name = $name;
  11. $this->group = $group;
  12. $this->id = $id;
  13. }
  14. public function validate(): bool
  15. {
  16. if (iconv_strlen($this->name) > 50 || iconv_strlen($this->name) < 2) {
  17. return false;
  18. }
  19. if (iconv_strlen($this->group) > 50 || iconv_strlen($this->group) < 2) {
  20. return false;
  21. }
  22. return true;
  23. }
  24. }