海南旅游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
4 years ago
  1. <?php
  2. namespace App\Models;
  3. use App\Events\DepositUpdate;
  4. use Illuminate\Database\Eloquent\Factories\HasFactory;
  5. use Illuminate\Database\Eloquent\SoftDeletes;
  6. class Supplier extends BaseModel
  7. {
  8. use HasFactory, SoftDeletes;
  9. protected $casts = ['publish_type' => 'json', 'license' => 'json'];
  10. protected $dispatchesEvents = [
  11. 'updated' => DepositUpdate::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 demand()
  21. {
  22. return $this->morphOne('App\Models\Demand', 'publisher');
  23. }
  24. public function demandUser()
  25. {
  26. return $this->morphOne('App\Models\Demand', 'biddingUser');
  27. }
  28. public function demandBidding()
  29. {
  30. return $this->morphOne('App\Models\DemandBidding', 'biddingUser');
  31. }
  32. public function agentProductItem()
  33. {
  34. return $this->hasMany(AgentProductItem::class);
  35. }
  36. public function workoorder()
  37. {
  38. return $this->morphOne('App\Models\Workorder', 'publisher');
  39. }
  40. public function point()
  41. {
  42. return $this->morphOne('App\Models\Workorder', 'point');
  43. }
  44. public function workoorderitem()
  45. {
  46. return $this->morphOne('App\Models\WorkorderItem', 'publisher');
  47. }
  48. public function statement()
  49. {
  50. return $this->morphMany('App\Models\Statement', 'user');
  51. }
  52. public function withdrawal()
  53. {
  54. return $this->morphOne('App\Models\Withdrawal', 'user');
  55. }
  56. public function province()
  57. {
  58. return $this->belongsTo('App\Models\ChinaArea', 'province_id','code');
  59. }
  60. public function city()
  61. {
  62. return $this->belongsTo('App\Models\ChinaArea', 'city_id','code');
  63. }
  64. public function area()
  65. {
  66. return $this->belongsTo('App\Models\ChinaArea', 'area_id','code');
  67. }
  68. public function settledOrder()
  69. {
  70. return $this->hasOne(SettledOrder::class, 'username', 'username')->where('user_type', 1);
  71. }
  72. }