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

51 lines
977 B

4 years ago
4 years ago
4 years ago
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. protected $table = 'agents';
  9. public function agentInfo()
  10. {
  11. return $this->hasOne(AgentInfo::class);
  12. }
  13. //密码修改
  14. public function setPasswordAttribute($value)
  15. {
  16. if (!empty($value)) {
  17. $this->attributes['password'] = password_hash($value, PASSWORD_BCRYPT);
  18. }
  19. }
  20. public function agentProduct()
  21. {
  22. return $this->hasMany(AgentProduct::class);
  23. }
  24. public function demand()
  25. {
  26. return $this->morphOne('App\Models\Demand', 'publisher');
  27. }
  28. public function demandUser()
  29. {
  30. return $this->morphOne('App\Models\Demand', 'biddingUser');
  31. }
  32. public function demandBidding()
  33. {
  34. return $this->morphOne('App\Models\DemandBidding', 'biddingUser');
  35. }
  36. public function workoorderitem()
  37. {
  38. return $this->morphOne('App\Models\WorkorderItem', 'publisher');
  39. }
  40. }