Client.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <?php
  2. namespace ModulesGarden\Servers\ProxmoxCloudVps\Core\Models\Whmcs;
  3. use \Illuminate\Database\Eloquent\Model as EloquentModel;
  4. /**
  5. * Description of Client
  6. *
  7. * @var int id
  8. * @var string uuid
  9. * @var string firstname
  10. * @var string lastname
  11. * @var string companyname
  12. * @var string email
  13. * @var string address1
  14. * @var string address2
  15. * @var string city
  16. * @var string state
  17. * @var string postcode
  18. * @var string country
  19. * @var string phonenumber
  20. * @var string password
  21. * @var string authmodule
  22. * @var string authdata
  23. * @var int currency
  24. * @var string defaultgateway
  25. * @var double credit
  26. * @var int taxexempt
  27. * @var int latefeeoveride
  28. * @var int overideduenotices
  29. * @var int separateinvoices
  30. * @var int disableautocc
  31. * @var datetime datecreated
  32. * @var string notes
  33. * @var int billingcid
  34. * @var int securityqid
  35. * @var string securityqans
  36. * @var int groupid
  37. * @var text cardtype
  38. * @var text cardlastfour
  39. * @var string cardnum
  40. * @var string startdate
  41. * @var string expdate
  42. * @var string issuenumber
  43. * @var string bankname
  44. * @var string banktype
  45. * @var string bankcode
  46. * @var string bankacct
  47. * @var string gatewayid
  48. * @var datetime lastlogin
  49. * @var string ip
  50. * @var string host
  51. * @var enum('Active', 'Inactive', 'Closed') status
  52. * @var string language
  53. * @var string pwresetkey
  54. * @var int emailoptout
  55. * @var int overrideautoclose
  56. * @var int allow_sso
  57. * @var int email_verified
  58. * @var timestamp created_at
  59. * @var timestamp updated_at
  60. * @var timestamp pwresetexpiry
  61. *
  62. * @author Paweł Złamaniec <pawel.zl@modulesgarden.com>
  63. */
  64. class Client extends EloquentModel
  65. {
  66. /**
  67. * Table name
  68. *
  69. * @var string
  70. */
  71. protected $table = 'tblclients';
  72. protected $primaryKey = 'id';
  73. /**
  74. * Eloquent guarded parameters
  75. * @var array
  76. */
  77. protected $guarded = ['id'];
  78. /**
  79. * Eloquent fillable parameters
  80. * @var array
  81. */
  82. protected $fillable = ['uuid', 'firstname', 'lastname', 'companyname', 'email', 'address1', 'address2', 'city', 'state', 'postcode', 'country', 'phonenumber', 'password', 'authmodule', 'authdata', 'currency', 'defaultgateway', 'credit', 'taxexempt', 'latefeeoveride', 'overideduenotices', 'separateinvoices', 'disableautocc', 'datecreated', 'notes', 'billingcid', 'securityqid', 'securityqans', 'groupid', 'cardtype', 'cardlastfour', 'bankname', 'banktype', 'gatewayid', 'lastlogin', 'ip', 'host', 'status', 'language', 'pwresetkey', 'emailoptout', 'overrideautoclose', 'allow_sso', 'email_verified', 'created_at', 'updated_at', 'pwresetexpiry'];
  83. /**
  84. * Indicates if the model should soft delete.
  85. *
  86. * @var bool
  87. */
  88. protected $softDelete = false;
  89. /**
  90. * Indicates if the model should be timestamped.
  91. *
  92. * @var bool
  93. */
  94. public $timestamps = false;
  95. public function __construct(array $attributes = [])
  96. {
  97. parent::__construct($attributes);
  98. }
  99. public function contacts()
  100. {
  101. return $this->hasMany("ModulesGarden\Servers\ProxmoxCloudVps\Core\Models\Whmcs\Contact", 'userid');
  102. }
  103. public function hostings()
  104. {
  105. return $this->hasMany("ModulesGarden\Servers\ProxmoxCloudVps\Core\Models\Whmcs\Hosting", 'userid');
  106. }
  107. public function currencyObj()
  108. {
  109. return $this->hasOne("ModulesGarden\Servers\ProxmoxCloudVps\Core\Models\Whmcs\Currency", 'id', 'currency');
  110. }
  111. public function orders()
  112. {
  113. return $this->hasMany("ModulesGarden\Servers\ProxmoxCloudVps\Core\Models\Whmcs\Order", "userid");
  114. }
  115. public function transactions()
  116. {
  117. return $this->hasMany("ModulesGarden\Servers\ProxmoxCloudVps\Core\Models\Whmcs\Transaction", "userid");
  118. }
  119. public function group()
  120. {
  121. return $this->belongsTo("ModulesGarden\Servers\ProxmoxCloudVps\Core\Models\Whmcs\ClientGroup", "groupid");
  122. }
  123. public function invoices()
  124. {
  125. return $this->hasMany("ModulesGarden\Servers\ProxmoxCloudVps\Core\Models\Whmcs\Invoice", "userid");
  126. }
  127. public function getFirstnameAttribute()
  128. {
  129. return preg_replace_callback("/(&#[0-9]+;)/", function ($m)
  130. {
  131. return mb_convert_encoding($m[1], "UTF-8", "HTML-ENTITIES");
  132. }, html_entity_decode($this->attributes["firstname"]));
  133. }
  134. public function getLastnameAttribute()
  135. {
  136. return preg_replace_callback("/(&#[0-9]+;)/", function ($m)
  137. {
  138. return mb_convert_encoding($m[1], "UTF-8", "HTML-ENTITIES");
  139. }, html_entity_decode($this->attributes["lastname"]));
  140. }
  141. }