ProductCustomerGroupPrice.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace Webkul\Product\Models;
  3. use Illuminate\Database\Eloquent\Factories\Factory;
  4. use Illuminate\Database\Eloquent\Factories\HasFactory;
  5. use Illuminate\Database\Eloquent\Model;
  6. use Webkul\Customer\Models\CustomerGroupProxy;
  7. use Webkul\Product\Contracts\ProductCustomerGroupPrice as ProductCustomerGroupPriceContract;
  8. use Webkul\Product\Database\Factories\ProductCustomerGroupPriceFactory;
  9. class ProductCustomerGroupPrice extends Model implements ProductCustomerGroupPriceContract
  10. {
  11. use HasFactory;
  12. /**
  13. * Add fillable property to the model.
  14. *
  15. * @var array
  16. */
  17. protected $fillable = [
  18. 'qty',
  19. 'value_type',
  20. 'value',
  21. 'priceable_id',
  22. 'priceable_type',
  23. 'customer_group_id',
  24. 'unique_id',
  25. ];
  26. /**
  27. * Get the owning priceable model (Product or ProductVariant).
  28. */
  29. public function priceable()
  30. {
  31. return $this->morphTo();
  32. }
  33. /**
  34. * Get the product that owns the customer group price.
  35. */
  36. public function customer_group()
  37. {
  38. return $this->belongsTo(CustomerGroupProxy::modelClass());
  39. }
  40. /**
  41. * Create a new factory instance for the model.
  42. */
  43. protected static function newFactory(): Factory
  44. {
  45. return ProductCustomerGroupPriceFactory::new();
  46. }
  47. }