| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- <?php
- namespace Webkul\BagistoApi\Models;
- use ApiPlatform\Metadata\ApiProperty;
- use ApiPlatform\Metadata\ApiResource;
- use Illuminate\Database\Eloquent\Relations\BelongsTo;
- use Symfony\Component\Serializer\Annotation\Groups;
- use Webkul\Product\Models\ProductCustomizableOptionPrice as BaseProductCustomizableOptionPrice;
- #[ApiResource(
- operations: [],
- graphQlOperations: [],
- )]
- class ProductCustomizableOptionPrice extends BaseProductCustomizableOptionPrice
- {
- /**
- * Get the customizable option that owns the price.
- */
- public function customizable_option(): BelongsTo
- {
- return $this->belongsTo(ProductCustomizableOption::class, 'product_customizable_option_id');
- }
- /**
- * Get id
- */
- #[ApiProperty(
- identifier: true,
- writable: false,
- readable: true
- )]
- #[Groups(['read'])]
- public function getId(): ?int
- {
- return $this->id;
- }
- /**
- * Get label
- */
- #[ApiProperty(
- writable: false,
- readable: true
- )]
- #[Groups(['read'])]
- public function getLabel(): ?string
- {
- return $this->label;
- }
- public function getPriceAttribute($value)
- {
- return $value !== null ? (float) core()->convertPrice((float) $value) : null;
- }
- /**
- * Get price
- */
- #[ApiProperty(
- writable: false,
- readable: true
- )]
- #[Groups(['read'])]
- public function getPrice(): ?float
- {
- return $this->price ? (float) $this->price : null;
- }
- public function getFormattedPriceAttribute(): ?string
- {
- return $this->price !== null ? core()->formatPrice($this->price) : null;
- }
- #[ApiProperty(writable: false, readable: true)]
- public function getFormatted_price(): ?string
- {
- return $this->getFormattedPriceAttribute();
- }
- /**
- * Get sort_order
- */
- #[ApiProperty(
- writable: false,
- readable: true
- )]
- #[Groups(['read'])]
- public function getSort_order(): ?int
- {
- return $this->sort_order;
- }
- }
|