Upgrade.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. namespace ModulesGarden\Servers\ProxmoxCloudVps\Core\Models\Whmcs;
  3. use \Illuminate\Database\Eloquent\Model as EloquentModel;
  4. /**
  5. * Description of Product
  6. *
  7. * @author Paweł Złamaniec <pawel.zl@modulesgarden.com>
  8. */
  9. class Upgrade extends EloquentModel
  10. {
  11. /**
  12. * Table name
  13. *
  14. * @var string
  15. */
  16. protected $table = 'tblupgrades';
  17. protected $primaryKey = 'id';
  18. /**
  19. * Eloquent guarded parameters
  20. * @var array
  21. */
  22. protected $guarded = ['id'];
  23. /**
  24. * Eloquent fillable parameters
  25. * @var array
  26. */
  27. protected $fillable = ['userid', 'orderid', 'type', 'date', 'relid', 'originalvalue', 'newvalue', 'new_cycle', 'amount', 'credit_amount', 'days_remaining', 'total_days_in_cycle', 'new_recurring_amount', 'recurringchange', 'status', 'paid'];
  28. /**
  29. * Indicates if the model should soft delete.
  30. *
  31. * @var bool
  32. */
  33. protected $softDelete = false;
  34. /**
  35. * Indicates if the model should be timestamped.
  36. *
  37. * @var bool
  38. */
  39. public $timestamps = false;
  40. public function __construct(array $attributes = [])
  41. {
  42. parent::__construct($attributes);
  43. }
  44. public function order()
  45. {
  46. return $this->belongsTo("ModulesGarden\Servers\ProxmoxCloudVps\Core\Models\Whmcs\Order", "orderid");
  47. }
  48. public function hosting()
  49. {
  50. if ($this->type != 'package')
  51. {
  52. return new \stdClass();
  53. }
  54. return $this->belongsTo("ModulesGarden\Servers\ProxmoxCloudVps\Core\Models\Whmcs\Hosting", "relid");
  55. }
  56. public function productFrom()
  57. {
  58. if ($this->type != 'package')
  59. {
  60. return new \stdClass();
  61. }
  62. return $this->belongsTo("ModulesGarden\Servers\ProxmoxCloudVps\Core\Models\Whmcs\Product", "originalvalue");
  63. }
  64. public function getNewBillingcycleAttribute()
  65. {
  66. $newvalue = explode(",", $this->newvalue);
  67. return $newvalue[1];
  68. }
  69. }