海南旅游SAAS
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.

38 lines
863 B

4 years ago
4 years ago
4 years ago
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Factories\HasFactory;
  4. use Illuminate\Database\Eloquent\SoftDeletes;
  5. class Agent extends BaseModel
  6. {
  7. use HasFactory, SoftDeletes;
  8. public function getLogoAttribute($value): string
  9. {
  10. return $value ? $this->host . $value : '';
  11. }
  12. public function getLicensePicAttribute($value): string
  13. {
  14. return $value ? $this->host . $value : '';
  15. }
  16. public function setPasswordAttribute($value)
  17. {
  18. //新增时
  19. if ($value && empty($this->attributes['password'])) {
  20. $this->attributes['password'] = $this->passMd5($value);
  21. }
  22. //编辑时
  23. else if ($value && !empty($this->attributes['password']) && $this->attributes['password'] != $value) {
  24. $this->attributes['password'] = $this->passMd5($value);
  25. }
  26. }
  27. public function agentInfo()
  28. {
  29. return $this->hasOne(AgentInfo::class);
  30. }
  31. }