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

92 lines
1.8 KiB

4 years ago
4 years ago
4 years ago
4 years ago
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 $casts = ['license' => 'json'];
  9. protected $table = 'agents';
  10. public function agentInfo()
  11. {
  12. return $this->hasOne(AgentInfo::class);
  13. }
  14. //密码修改
  15. public function setPasswordAttribute($value)
  16. {
  17. if (!empty($value)) {
  18. $this->attributes['password'] = password_hash($value, PASSWORD_BCRYPT);
  19. }
  20. }
  21. public function agentProduct()
  22. {
  23. return $this->hasMany(AgentProduct::class);
  24. }
  25. public function miniUpload()
  26. {
  27. return $this->hasOne(MiniProgramUploadLog::class)->orderBy('id', 'desc');
  28. }
  29. public function demand()
  30. {
  31. return $this->morphOne('App\Models\Demand', 'publisher');
  32. }
  33. public function demandUser()
  34. {
  35. return $this->morphOne('App\Models\Demand', 'biddingUser');
  36. }
  37. public function demandBidding()
  38. {
  39. return $this->morphOne('App\Models\DemandBidding', 'biddingUser');
  40. }
  41. public function workoorder()
  42. {
  43. return $this->morphOne('App\Models\Workorder', 'publisher');
  44. }
  45. public function workoorderitem()
  46. {
  47. return $this->morphOne('App\Models\WorkorderItem', 'publisher');
  48. }
  49. public function statement()
  50. {
  51. return $this->morphMany('App\Models\Statement', 'user');
  52. }
  53. public function withdrawal()
  54. {
  55. return $this->morphOne('App\Models\Withdrawal', 'user');
  56. }
  57. public function province()
  58. {
  59. return $this->belongsTo('App\Models\ChinaArea', 'province_id','code');
  60. }
  61. public function city()
  62. {
  63. return $this->belongsTo('App\Models\ChinaArea', 'city_id','code');
  64. }
  65. public function area()
  66. {
  67. return $this->belongsTo('App\Models\ChinaArea', 'area_id','code');
  68. }
  69. public function settledOrder()
  70. {
  71. return $this->hasOne(SettledOrder::class, 'username', 'username')->where('user_type', 2);
  72. }
  73. }