DomainPricing.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. namespace ThurData\Servers\KerioEmail\Core\Models\Whmcs;
  3. use \Illuminate\Database\Eloquent\Model as EloquentModel;
  4. /**
  5. * Description of Domain Pricing
  6. *
  7. * @var id
  8. * @var extension
  9. * @var dnsmanagement
  10. * @var emailforwarding
  11. * @var idprotection
  12. * @var eppcode
  13. * @var autoreg
  14. * @var order
  15. * @var group
  16. *
  17. * @autor ThurData <info@thurdata.ch>
  18. */
  19. class DomainPricing extends EloquentModel
  20. {
  21. /**
  22. * Table name
  23. *
  24. * @var string
  25. */
  26. protected $table = 'tbldomainpricing';
  27. protected $primaryKey = 'id';
  28. /**
  29. * Eloquent guarded parameters
  30. * @var array
  31. */
  32. protected $guarded = ['id'];
  33. /**
  34. * Eloquent fillable parameters
  35. * @var array
  36. */
  37. protected $fillable = ['id', 'extension', 'dnsmanagement', 'emailforwarding', 'idprotection', 'eppcode', 'autoreg', 'order', 'group'];
  38. /**
  39. * Indicates if the model should soft delete.
  40. *
  41. * @var bool
  42. */
  43. protected $softDelete = false;
  44. public function __construct(array $attributes = [])
  45. {
  46. parent::__construct($attributes);
  47. }
  48. /**
  49. * Indicates if the model should be timestamped.
  50. *
  51. * @var bool
  52. */
  53. public $timestamps = false;
  54. public function getExtensionNoDotAttribute()
  55. {
  56. return substr($this->extension, 1);
  57. }
  58. public function scopeWithPrincing($query)
  59. {
  60. return $query->join('tblpricing', function($join) {
  61. $join->on('tbldomainpricing.id', 'LIKE', 'tblpricing.relid');
  62. }
  63. );
  64. }
  65. public function scopeGroupByExtension($query)
  66. {
  67. return $query->groupBy("tbldomainpricing.extension");
  68. }
  69. }