ProductConfigOption.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. namespace ThurData\Servers\KerioEmail\Core\Models\Whmcs;
  3. use \Illuminate\Database\Eloquent\Model as EloquentModel;
  4. use ThurData\Servers\KerioEmail\App\Models\Whmcs\ProductConfigLinks;
  5. /**
  6. * Description of Product
  7. *
  8. * @autor ThurData <info@thurdata.ch>
  9. */
  10. class ProductConfigOption extends EloquentModel
  11. {
  12. /**
  13. * Table name
  14. *
  15. * @var string
  16. */
  17. protected $table = 'tblproductconfigoptions';
  18. protected $primaryKey = 'id';
  19. /**
  20. * Eloquent guarded parameters
  21. * @var array
  22. */
  23. protected $guarded = ['id'];
  24. /**
  25. * Eloquent fillable parameters
  26. * @var array
  27. */
  28. protected $fillable = ['gid', 'optionname', 'optiontype', 'qtyminimum', 'qtymaximum', 'order', 'hidden'];
  29. /**
  30. * Indicates if the model should soft delete.
  31. *
  32. * @var bool
  33. */
  34. protected $softDelete = false;
  35. /**
  36. * Indicates if the model should be timestamped.
  37. *
  38. * @var bool
  39. */
  40. public $timestamps = false;
  41. public function __construct(array $attributes = [])
  42. {
  43. parent::__construct($attributes);
  44. }
  45. public function links()
  46. {
  47. return $this->hasMany(ProductConfigLinks::class, 'gid', 'gid');
  48. }
  49. public function suboptions()
  50. {
  51. return $this->hasMany("ThurData\Servers\KerioEmail\Core\Models\Whmcs\ProductConfigOptionSub", "configid");
  52. }
  53. public function isLinkedToProduct($id)
  54. {
  55. foreach($this->links as $link)
  56. {
  57. if((int) $link->pid === (int) $id)
  58. {
  59. return true;
  60. }
  61. }
  62. return false;
  63. }
  64. }