| 1 | <?php |
||
| 8 | class ShopInventory |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * Payment Categories of the Country. |
||
| 12 | * |
||
| 13 | * @var PaymentCategory[] |
||
| 14 | */ |
||
| 15 | public $paymentCategories = []; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * Inventory Items. |
||
| 19 | * |
||
| 20 | * @var array |
||
| 21 | */ |
||
| 22 | public $pricePoints = []; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * If double Credits are Enabled. |
||
| 26 | * |
||
| 27 | * @var bool |
||
| 28 | */ |
||
| 29 | public $doubleCredits = false; |
||
| 30 | |||
| 31 | /** |
||
| 32 | * Country Meta Data. |
||
| 33 | * |
||
| 34 | * @var Country |
||
| 35 | */ |
||
| 36 | public $country = null; |
||
| 37 | |||
| 38 | /** |
||
| 39 | * Create a Shop Inventory. |
||
| 40 | * |
||
| 41 | * @param Country $country |
||
| 42 | */ |
||
| 43 | public function __construct(Country $country) |
||
| 44 | { |
||
| 45 | $this->setCountry($country); |
||
| 46 | $this->setPaymentCategories($country->countryCode); |
||
| 47 | $this->setPricePoints($country->countryCode); |
||
| 48 | } |
||
| 49 | |||
| 50 | /** |
||
| 51 | * Set the Country Metadata. |
||
| 52 | * |
||
| 53 | * @param Country $country |
||
| 54 | */ |
||
| 55 | public function setCountry(Country $country) |
||
| 56 | { |
||
| 57 | $this->country = $country; |
||
| 58 | } |
||
| 59 | |||
| 60 | /** |
||
| 61 | * Set the Payment Methods. |
||
| 62 | * |
||
| 63 | * @param string $countryCode |
||
| 64 | */ |
||
| 65 | public function setPaymentCategories(string $countryCode) |
||
| 66 | { |
||
| 67 | $paymentMethods = []; |
||
| 68 | |||
| 69 | foreach (PaymentCategory::where('country_code', $countryCode)->get(['payment_type']) as $paymentMethod) { |
||
| 70 | $paymentMethods[] = $paymentMethod->payment_type; |
||
| 71 | } |
||
| 72 | |||
| 73 | $this->paymentCategories = $paymentMethods; |
||
| 74 | } |
||
| 75 | |||
| 76 | /** |
||
| 77 | * Get All Shop Items from this Country Code. |
||
| 78 | * |
||
| 79 | * @param string $countryCode |
||
| 80 | */ |
||
| 81 | public function setPricePoints(string $countryCode) |
||
| 85 | } |
||
| 86 |