CustomField.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. namespace ThurData\Servers\KerioEmail\Core\Models\Whmcs;
  3. use \Illuminate\Database\Eloquent\Model as EloquentModel;
  4. /**
  5. * Description of CustomField
  6. *
  7. * @var id
  8. * @var type
  9. * @var relid
  10. * @var fieldname
  11. * @var fieldtype
  12. * @var description
  13. * @var fieldoptions
  14. * @var regexpr
  15. * @var adminonly
  16. * @var required
  17. * @var showorder
  18. * @var showinvoice
  19. * @var sortorder
  20. * @var created_at
  21. * @var updated_at
  22. *
  23. * @author Paweł Złamaniec <pawel.zl@thurdata.com>
  24. */
  25. class CustomField extends EloquentModel
  26. {
  27. /**
  28. * Table name
  29. *
  30. * @var string
  31. */
  32. protected $table = 'tblcustomfields';
  33. protected $primaryKey = 'id';
  34. /**
  35. * Eloquent guarded parameters
  36. * @var array
  37. */
  38. protected $guarded = ['id'];
  39. /**
  40. * Eloquent fillable parameters
  41. * @var array
  42. */
  43. protected $fillable = ['type', 'relid', 'fieldname', 'fieldtype', 'description', 'fieldoptions', 'regexpr', 'adminonly', 'required', 'showorder', 'showinvoice', 'sortorder'];
  44. /**
  45. * Indicates if the model should soft delete.
  46. *
  47. * @var bool
  48. */
  49. protected $softDelete = false;
  50. /**
  51. * Indicates if the model should be timestamped.
  52. *
  53. * @var bool
  54. */
  55. public $timestamps = true;
  56. public function __construct(array $attributes = [])
  57. {
  58. parent::__construct($attributes);
  59. }
  60. public function getValueByRelid($relid)
  61. {
  62. $field = new CustomFieldValue();
  63. $result = $field->where("fieldid", $this->attributes["id"])->where("relid", $relid)->first();
  64. return $result->value;
  65. }
  66. }