code
stringlengths 31
1.39M
| docstring
stringlengths 23
16.8k
| func_name
stringlengths 1
126
| language
stringclasses 1
value | repo
stringlengths 7
63
| path
stringlengths 7
166
| url
stringlengths 50
220
| license
stringclasses 7
values |
---|---|---|---|---|---|---|---|
public function getPrice(?string $currency = null): ?float
{
return $this->__getPrice($currency) ?: $this->product->getPrice($currency);
} | Get the price by the given type and currency. | getPrice | php | conedevelopment/bazar | src/Models/Variant.php | https://github.com/conedevelopment/bazar/blob/master/src/Models/Variant.php | MIT |
public function toItem(Checkoutable $checkoutable, array $attributes = []): Item
{
return $this->items()->make(array_merge([
'name' => $this->name,
'price' => $this->getPrice($checkoutable->getCurrency()),
'quantity' => 1,
], $attributes))->setRelation('buyable', $this);
} | Get the item representation of the buyable instance. | toItem | php | conedevelopment/bazar | src/Models/Variant.php | https://github.com/conedevelopment/bazar/blob/master/src/Models/Variant.php | MIT |
public function via(object $notifiable): array
{
return ['mail'];
} | Get the notification's delivery channels.
@return array<int, string> | via | php | conedevelopment/bazar | src/Notifications/OrderDetails.php | https://github.com/conedevelopment/bazar/blob/master/src/Notifications/OrderDetails.php | MIT |
public function toMail(object $notifiable): MailMessage
{
return (new MailMessage)
->subject(__('Order Details (#:order)', ['order' => $this->order->getKey()]))
->markdown('root::mail.order-details', [
'order' => $this->order,
]);
} | Get the mail representation of the notification. | toMail | php | conedevelopment/bazar | src/Notifications/OrderDetails.php | https://github.com/conedevelopment/bazar/blob/master/src/Notifications/OrderDetails.php | MIT |
public function addConstraints(): void
{
parent::addConstraints();
$this->getQuery()->where($this->getQuery()->qualifyColumn('key'), 'like', 'price_%');
} | Set the base constraints on the relation query. | addConstraints | php | conedevelopment/bazar | src/Relations/Prices.php | https://github.com/conedevelopment/bazar/blob/master/src/Relations/Prices.php | MIT |
public function calculate(Discountable $model): float
{
return $this->disabled
? $model->discount
: $this->items->sum(function (int|float|Closure|Discount $discount) use ($model): float {
return $this->process($model, $discount);
});
} | Calculate the total of the processed discounts. | calculate | php | conedevelopment/bazar | src/Repositories/DiscountRepository.php | https://github.com/conedevelopment/bazar/blob/master/src/Repositories/DiscountRepository.php | MIT |
public function remove(string $name): void
{
$this->items->forget($name);
} | Remove the item by the given name. | remove | php | conedevelopment/bazar | src/Repositories/Repository.php | https://github.com/conedevelopment/bazar/blob/master/src/Repositories/Repository.php | MIT |
public function getModel(): string
{
return $this->model::getProxiedClass();
} | Get the model for the resource. | getModel | php | conedevelopment/bazar | src/Resources/CategoryResource.php | https://github.com/conedevelopment/bazar/blob/master/src/Resources/CategoryResource.php | MIT |
public function getModel(): string
{
return $this->model::getProxiedClass();
} | Get the model for the resource. | getModel | php | conedevelopment/bazar | src/Resources/OrderResource.php | https://github.com/conedevelopment/bazar/blob/master/src/Resources/OrderResource.php | MIT |
public function getModel(): string
{
return $this->model::getProxiedClass();
} | Get the model for the resource. | getModel | php | conedevelopment/bazar | src/Resources/ProductResource.php | https://github.com/conedevelopment/bazar/blob/master/src/Resources/ProductResource.php | MIT |
public function getModel(): string
{
return $this->model::getProxiedClass();
} | Get the model for the resource. | getModel | php | conedevelopment/bazar | src/Resources/PropertyResource.php | https://github.com/conedevelopment/bazar/blob/master/src/Resources/PropertyResource.php | MIT |
public function getModel(): string
{
return $this->model::getProxiedClass();
} | Get the model for the resource. | getModel | php | conedevelopment/bazar | src/Resources/TaxRateResource.php | https://github.com/conedevelopment/bazar/blob/master/src/Resources/TaxRateResource.php | MIT |
public function getAvailableDrivers(?Checkoutable $model = null): array
{
foreach (array_keys(array_diff_key($this->customCreators, parent::getDrivers())) as $key) {
if (! isset($this->drivers[$key])) {
$this->drivers[$key] = $this->createDriver($key);
}
}
return array_filter(parent::getDrivers(), static function (Driver $driver) use ($model): bool {
return is_null($model) ? $driver->enabled() : $driver->available($model);
});
} | Get the available drivers for the given model. | getAvailableDrivers | php | conedevelopment/bazar | src/Shipping/Manager.php | https://github.com/conedevelopment/bazar/blob/master/src/Shipping/Manager.php | MIT |
public static function northAmerica(): array
{
return [
'AG' => Lang::get('bazar::countries.AG'),
'BS' => Lang::get('bazar::countries.BS'),
'BB' => Lang::get('bazar::countries.BB'),
'BM' => Lang::get('bazar::countries.BM'),
'BZ' => Lang::get('bazar::countries.BZ'),
'VG' => Lang::get('bazar::countries.VG'),
'CA' => Lang::get('bazar::countries.CA'),
'KY' => Lang::get('bazar::countries.KY'),
'CR' => Lang::get('bazar::countries.CR'),
'CU' => Lang::get('bazar::countries.CU'),
'DM' => Lang::get('bazar::countries.DM'),
'DO' => Lang::get('bazar::countries.DO'),
'SV' => Lang::get('bazar::countries.SV'),
'GL' => Lang::get('bazar::countries.GL'),
'GD' => Lang::get('bazar::countries.GD'),
'GP' => Lang::get('bazar::countries.GP'),
'GT' => Lang::get('bazar::countries.GT'),
'HT' => Lang::get('bazar::countries.HT'),
'HN' => Lang::get('bazar::countries.HN'),
'JM' => Lang::get('bazar::countries.JM'),
'MQ' => Lang::get('bazar::countries.MQ'),
'MX' => Lang::get('bazar::countries.MX'),
'MS' => Lang::get('bazar::countries.MS'),
'CW' => Lang::get('bazar::countries.CW'),
'AW' => Lang::get('bazar::countries.AW'),
'SX' => Lang::get('bazar::countries.SX'),
'BQ' => Lang::get('bazar::countries.BQ'),
'NI' => Lang::get('bazar::countries.NI'),
'PA' => Lang::get('bazar::countries.PA'),
'PR' => Lang::get('bazar::countries.PR'),
'BL' => Lang::get('bazar::countries.BL'),
'KN' => Lang::get('bazar::countries.KN'),
'AI' => Lang::get('bazar::countries.AI'),
'LC' => Lang::get('bazar::countries.LC'),
'MF' => Lang::get('bazar::countries.MF'),
'PM' => Lang::get('bazar::countries.PM'),
'VC' => Lang::get('bazar::countries.VC'),
'TT' => Lang::get('bazar::countries.TT'),
'TC' => Lang::get('bazar::countries.TC'),
'US' => Lang::get('bazar::countries.US'),
'VI' => Lang::get('bazar::countries.VI'),
];
} | Get all the North American countries. | northAmerica | php | conedevelopment/bazar | src/Support/Countries.php | https://github.com/conedevelopment/bazar/blob/master/src/Support/Countries.php | MIT |
public static function southAmerica(): array
{
return [
'AR' => Lang::get('bazar::countries.AR'),
'BO' => Lang::get('bazar::countries.BO'),
'BR' => Lang::get('bazar::countries.BR'),
'CL' => Lang::get('bazar::countries.CL'),
'CO' => Lang::get('bazar::countries.CO'),
'EC' => Lang::get('bazar::countries.EC'),
'FK' => Lang::get('bazar::countries.FK'),
'GF' => Lang::get('bazar::countries.GF'),
'GY' => Lang::get('bazar::countries.GY'),
'PY' => Lang::get('bazar::countries.PY'),
'PE' => Lang::get('bazar::countries.PE'),
'SR' => Lang::get('bazar::countries.SR'),
'UY' => Lang::get('bazar::countries.UY'),
'VE' => Lang::get('bazar::countries.VE'),
];
} | Get all the South American countries. | southAmerica | php | conedevelopment/bazar | src/Support/Countries.php | https://github.com/conedevelopment/bazar/blob/master/src/Support/Countries.php | MIT |
public static function name(string $country): string
{
$countries = array_merge(...static::all());
return $countries[$country] ?? $country;
} | Get the name of the given country. | name | php | conedevelopment/bazar | src/Support/Countries.php | https://github.com/conedevelopment/bazar/blob/master/src/Support/Countries.php | MIT |
public static function allByContient(): array
{
return [
__('Africa') => static::africa(),
__('Antarctica') => static::antarctica(),
__('Asia') => static::asia(),
__('Europe') => static::europe(),
__('North America') => static::northAmerica(),
__('South America') => static::southAmerica(),
__('Oceania') => static::oceania(),
];
} | Get all the countries grouped by their continent. | allByContient | php | conedevelopment/bazar | src/Support/Countries.php | https://github.com/conedevelopment/bazar/blob/master/src/Support/Countries.php | MIT |
public function jsonSerialize(): mixed
{
return $this->format();
} | Get the JSON serializable format of the currency. | jsonSerialize | php | conedevelopment/bazar | src/Support/Currency.php | https://github.com/conedevelopment/bazar/blob/master/src/Support/Currency.php | MIT |
public function available(Checkoutable $model): bool
{
return $this->enabled();
} | Determine if the driver is available for the given model. | available | php | conedevelopment/bazar | src/Support/Driver.php | https://github.com/conedevelopment/bazar/blob/master/src/Support/Driver.php | MIT |
public function enabled(): bool
{
return $this->enabled;
} | Determine if the driver is enabled. | enabled | php | conedevelopment/bazar | src/Support/Driver.php | https://github.com/conedevelopment/bazar/blob/master/src/Support/Driver.php | MIT |
public function disabled(): bool
{
return ! $this->enabled();
} | Determine if the driver is disabled. | disabled | php | conedevelopment/bazar | src/Support/Driver.php | https://github.com/conedevelopment/bazar/blob/master/src/Support/Driver.php | MIT |
public function getName(): string
{
$name = Str::of(static::class)->classBasename()->replace('Driver', '')->headline()->value();
return __($name);
} | Get the name of the driver. | getName | php | conedevelopment/bazar | src/Support/Driver.php | https://github.com/conedevelopment/bazar/blob/master/src/Support/Driver.php | MIT |
protected static function getFacadeAccessor(): string
{
return Manager::class;
} | Get the registered name of the component. | getFacadeAccessor | php | conedevelopment/bazar | src/Support/Facades/Cart.php | https://github.com/conedevelopment/bazar/blob/master/src/Support/Facades/Cart.php | MIT |
protected static function getFacadeAccessor(): string
{
return DiscountRepository::class;
} | Get the registered name of the component. | getFacadeAccessor | php | conedevelopment/bazar | src/Support/Facades/Discount.php | https://github.com/conedevelopment/bazar/blob/master/src/Support/Facades/Discount.php | MIT |
protected static function getFacadeAccessor(): string
{
return Manager::class;
} | Get the registered name of the component. | getFacadeAccessor | php | conedevelopment/bazar | src/Support/Facades/Gateway.php | https://github.com/conedevelopment/bazar/blob/master/src/Support/Facades/Gateway.php | MIT |
protected static function getFacadeAccessor(): string
{
return Manager::class;
} | Get the registered name of the component. | getFacadeAccessor | php | conedevelopment/bazar | src/Support/Facades/Shipping.php | https://github.com/conedevelopment/bazar/blob/master/src/Support/Facades/Shipping.php | MIT |
public function address(): MorphOne
{
return $this->morphOne(Address::getProxiedClass(), 'addressable')->withDefault();
} | Get the address for the model. | address | php | conedevelopment/bazar | src/Traits/Addressable.php | https://github.com/conedevelopment/bazar/blob/master/src/Traits/Addressable.php | MIT |
public function carts(): HasMany
{
return $this->hasMany(Cart::getProxiedClass());
} | Get the carts for the user. | carts | php | conedevelopment/bazar | src/Traits/AsCustomer.php | https://github.com/conedevelopment/bazar/blob/master/src/Traits/AsCustomer.php | MIT |
public function cart(): HasOne
{
return $this->hasOne(Cart::getProxiedClass())->latestOfMany();
} | Get the active cart for the user. | cart | php | conedevelopment/bazar | src/Traits/AsCustomer.php | https://github.com/conedevelopment/bazar/blob/master/src/Traits/AsCustomer.php | MIT |
public function orders(): HasMany
{
return $this->hasMany(Order::getProxiedClass());
} | Get the orders for the user. | orders | php | conedevelopment/bazar | src/Traits/AsCustomer.php | https://github.com/conedevelopment/bazar/blob/master/src/Traits/AsCustomer.php | MIT |
public function addresses(): MorphMany
{
return $this->morphMany(Address::getProxiedClass(), 'addressable');
} | Get the addresses for the user. | addresses | php | conedevelopment/bazar | src/Traits/AsCustomer.php | https://github.com/conedevelopment/bazar/blob/master/src/Traits/AsCustomer.php | MIT |
public function address(): MorphOne
{
return $this->addresses()->one()->ofMany([
'default' => 'max',
'id' => 'min',
])->withDefault();
} | Get the default address for the user. | address | php | conedevelopment/bazar | src/Traits/AsCustomer.php | https://github.com/conedevelopment/bazar/blob/master/src/Traits/AsCustomer.php | MIT |
public function prices(): Prices
{
$query = $this->newRelatedInstance(Price::class)->newQuery();
[$type, $id] = $this->getMorphs('metable', null, null);
return new Prices($query, $this, $query->qualifyColumn($type), $query->qualifyColumn($id), $this->getKeyName());
} | Get the prices for the model. | prices | php | conedevelopment/bazar | src/Traits/HasPrices.php | https://github.com/conedevelopment/bazar/blob/master/src/Traits/HasPrices.php | MIT |
protected function price(): Attribute
{
return new Attribute(
get: fn (): ?float => $this->getPrice(),
);
} | Get the price attribute.
@return \Illuminate\Database\Eloquent\Casts\Attribute<float|null, never> | price | php | conedevelopment/bazar | src/Traits/HasPrices.php | https://github.com/conedevelopment/bazar/blob/master/src/Traits/HasPrices.php | MIT |
protected function formattedPrice(): Attribute
{
return new Attribute(
get: fn (): ?string => $this->getFormattedPrice(),
);
} | Get the formatted price attribute.
@return \Illuminate\Database\Eloquent\Casts\Attribute<string|null, never> | formattedPrice | php | conedevelopment/bazar | src/Traits/HasPrices.php | https://github.com/conedevelopment/bazar/blob/master/src/Traits/HasPrices.php | MIT |
public function getPrice(?string $currency = null): ?float
{
$currency ??= Bazar::getCurrency();
$key = sprintf('price_%s', strtolower($currency));
$meta = $this->prices->firstWhere('key', $key);
return is_null($meta) ? null : $meta->value;
} | Get the price by the given type and currency. | getPrice | php | conedevelopment/bazar | src/Traits/HasPrices.php | https://github.com/conedevelopment/bazar/blob/master/src/Traits/HasPrices.php | MIT |
public function getFormattedPrice(?string $currency = null): ?string
{
$currency ??= Bazar::getCurrency();
$price = $this->getPrice($currency);
return is_null($price) ? null : (new Currency($price, $currency))->format();
} | Get the formatted price by the given type and currency. | getFormattedPrice | php | conedevelopment/bazar | src/Traits/HasPrices.php | https://github.com/conedevelopment/bazar/blob/master/src/Traits/HasPrices.php | MIT |
public function isFree(): bool
{
$price = $this->getPrice();
return is_null($price) || $price === 0.0;
} | Determine if the stockable model is free. | isFree | php | conedevelopment/bazar | src/Traits/HasPrices.php | https://github.com/conedevelopment/bazar/blob/master/src/Traits/HasPrices.php | MIT |
public function propertyValues(): MorphToMany
{
return $this->morphToMany(PropertyValue::getProxiedClass(), 'buyable', 'bazar_buyable_property_value');
} | Get the property values for the model. | propertyValues | php | conedevelopment/bazar | src/Traits/HasProperties.php | https://github.com/conedevelopment/bazar/blob/master/src/Traits/HasProperties.php | MIT |
public function properties(): HasManyThrough
{
return $this->hasManyThrough(Property::getProxiedClass(), PropertyValue::getProxiedClass(), 'bazar_buyable_property_value.buyable_id', 'id', 'id', 'property_id')
->join('bazar_buyable_property_value', 'bazar_buyable_property_value.property_value_id', '=', 'bazar_property_values.id')
->where('bazar_buyable_property_value.buyable_type', static::class);
} | Get the properties for the model. | properties | php | conedevelopment/bazar | src/Traits/HasProperties.php | https://github.com/conedevelopment/bazar/blob/master/src/Traits/HasProperties.php | MIT |
public function items(): MorphMany
{
return $this->morphMany(Item::getProxiedClass(), 'buyable');
} | Get the items for the product. | items | php | conedevelopment/bazar | src/Traits/InteractsWithCheckoutables.php | https://github.com/conedevelopment/bazar/blob/master/src/Traits/InteractsWithCheckoutables.php | MIT |
public function orders(): HasManyThrough
{
return $this->hasManyThrough(Order::getProxiedClass(), Item::getProxiedClass(), 'buyable_id', 'id', 'id', 'checkoutable_id')
->where('checkoutable_type', Order::getProxiedClass())
->where('buyable_type', static::class);
} | Get the products for the model.
@return \Illuminate\Database\Eloquent\Relations\HasManyThrough<\Cone\Bazar\Models\Order> | orders | php | conedevelopment/bazar | src/Traits/InteractsWithCheckoutables.php | https://github.com/conedevelopment/bazar/blob/master/src/Traits/InteractsWithCheckoutables.php | MIT |
public function carts(): HasManyThrough
{
return $this->hasManyThrough(Cart::getProxiedClass(), Item::getProxiedClass(), 'buyable_id', 'id', 'id', 'checkoutable_id')
->where('checkoutable_type', Cart::getProxiedClass())
->where('buyable_type', static::class);
} | Get the carts for the product.
@return \Illuminate\Database\Eloquent\Relations\HasManyThrough<\Cone\Bazar\Models\Cart> | carts | php | conedevelopment/bazar | src/Traits/InteractsWithCheckoutables.php | https://github.com/conedevelopment/bazar/blob/master/src/Traits/InteractsWithCheckoutables.php | MIT |
protected function formattedDiscount(): Attribute
{
return new Attribute(
get: function (): string {
return $this->getFormattedDiscount();
}
);
} | Get the formatted discount attribute.
@return \Illuminate\Database\Eloquent\Casts\Attribute<string, never> | formattedDiscount | php | conedevelopment/bazar | src/Traits/InteractsWithDiscounts.php | https://github.com/conedevelopment/bazar/blob/master/src/Traits/InteractsWithDiscounts.php | MIT |
public function user(): BelongsTo
{
return $this->belongsTo(get_class(App::make(User::class)));
} | Get the user for the model. | user | php | conedevelopment/bazar | src/Traits/InteractsWithItems.php | https://github.com/conedevelopment/bazar/blob/master/src/Traits/InteractsWithItems.php | MIT |
public function items(): MorphMany
{
return $this->morphMany(Item::getProxiedClass(), 'checkoutable');
} | Get the items for the model. | items | php | conedevelopment/bazar | src/Traits/InteractsWithItems.php | https://github.com/conedevelopment/bazar/blob/master/src/Traits/InteractsWithItems.php | MIT |
public function shipping(): MorphOne
{
return $this->morphOne(Shipping::getProxiedClass(), 'shippable')->withDefault([
'driver' => ShippingManager::getDefaultDriver(),
]);
} | Get the shipping for the model. | shipping | php | conedevelopment/bazar | src/Traits/InteractsWithItems.php | https://github.com/conedevelopment/bazar/blob/master/src/Traits/InteractsWithItems.php | MIT |
protected function currency(): Attribute
{
return new Attribute(
get: static function (?string $value = null): string {
return strtoupper($value ?: Bazar::getCurrency());
}
);
} | Get the currency attribute.
@return \Illuminate\Database\Eloquent\Casts\Attribute<string, never> | currency | php | conedevelopment/bazar | src/Traits/InteractsWithItems.php | https://github.com/conedevelopment/bazar/blob/master/src/Traits/InteractsWithItems.php | MIT |
protected function total(): Attribute
{
return new Attribute(
get: function (): float {
return $this->getTotal();
}
);
} | Get the total attribute.
@return \Illuminate\Database\Eloquent\Casts\Attribute<float, never> | total | php | conedevelopment/bazar | src/Traits/InteractsWithItems.php | https://github.com/conedevelopment/bazar/blob/master/src/Traits/InteractsWithItems.php | MIT |
protected function formattedTotal(): Attribute
{
return new Attribute(
get: function (): string {
return $this->getFormattedTotal();
}
);
} | Get the formatted total attribute.
@return \Illuminate\Database\Eloquent\Casts\Attribute<string, never> | formattedTotal | php | conedevelopment/bazar | src/Traits/InteractsWithItems.php | https://github.com/conedevelopment/bazar/blob/master/src/Traits/InteractsWithItems.php | MIT |
protected function subtotal(): Attribute
{
return new Attribute(
get: function (): float {
return $this->getSubtotal();
}
);
} | Get the subtotal attribute.
@return \Illuminate\Database\Eloquent\Casts\Attribute<float, never> | subtotal | php | conedevelopment/bazar | src/Traits/InteractsWithItems.php | https://github.com/conedevelopment/bazar/blob/master/src/Traits/InteractsWithItems.php | MIT |
protected function formattedSubtotal(): Attribute
{
return new Attribute(
get: function (): string {
return $this->getFormattedSubtotal();
}
);
} | Get the formatted subtotal attribute.
@return \Illuminate\Database\Eloquent\Casts\Attribute<string, never> | formattedSubtotal | php | conedevelopment/bazar | src/Traits/InteractsWithItems.php | https://github.com/conedevelopment/bazar/blob/master/src/Traits/InteractsWithItems.php | MIT |
protected function tax(): Attribute
{
return new Attribute(
get: function (): float {
return $this->getTax();
}
);
} | Get the tax attribute.
@return \Illuminate\Database\Eloquent\Casts\Attribute<float, never> | tax | php | conedevelopment/bazar | src/Traits/InteractsWithItems.php | https://github.com/conedevelopment/bazar/blob/master/src/Traits/InteractsWithItems.php | MIT |
protected function formattedTax(): Attribute
{
return new Attribute(
get: function (): string {
return $this->getFormattedTax();
}
);
} | Get the formatted tax attribute.
@return \Illuminate\Database\Eloquent\Casts\Attribute<string, never> | formattedTax | php | conedevelopment/bazar | src/Traits/InteractsWithItems.php | https://github.com/conedevelopment/bazar/blob/master/src/Traits/InteractsWithItems.php | MIT |
public function needsShipping(): bool
{
return $this->items->some(static function (Item $item): bool {
return ! $item->isFee()
&& $item->buyable instanceof Inventoryable
&& $item->buyable->isPhysical();
});
} | Determine if the model needs shipping. | needsShipping | php | conedevelopment/bazar | src/Traits/InteractsWithItems.php | https://github.com/conedevelopment/bazar/blob/master/src/Traits/InteractsWithItems.php | MIT |
public function getFeeTotal(): float
{
$value = $this->getFees()->sum(static function (LineItem $item): float {
return $item->getSubtotal();
});
return round($value < 0 ? 0 : $value, 2);
} | Get the checkoutable model's fee total. | getFeeTotal | php | conedevelopment/bazar | src/Traits/InteractsWithItems.php | https://github.com/conedevelopment/bazar/blob/master/src/Traits/InteractsWithItems.php | MIT |
public function findItem(array $attributes): ?Item
{
$attributes = array_merge(['properties' => null], $attributes, [
'checkoutable_id' => $this->getKey(),
'checkoutable_type' => static::class,
]);
return $this->items->first(static function (Item $item) use ($attributes): bool {
return empty(array_diff(
array_filter(Arr::dot($attributes)),
array_filter(Arr::dot(array_merge(['properties' => null], $item->withoutRelations()->toArray())))
));
});
} | Find an item by its attributes or make a new instance. | findItem | php | conedevelopment/bazar | src/Traits/InteractsWithItems.php | https://github.com/conedevelopment/bazar/blob/master/src/Traits/InteractsWithItems.php | MIT |
public function mergeItem(Item $item): Item
{
$stored = $this->findItem(
$item->only(['properties', 'buyable_id', 'buyable_type'])
);
if (is_null($stored)) {
$item->checkoutable()->associate($this);
$item->setRelation('checkoutable', $this->withoutRelations());
$this->items->push($item);
return $item;
}
$stored->quantity += $item->quantity;
return $stored;
} | Merge the given item into the collection. | mergeItem | php | conedevelopment/bazar | src/Traits/InteractsWithItems.php | https://github.com/conedevelopment/bazar/blob/master/src/Traits/InteractsWithItems.php | MIT |
public function isVirtual(): bool
{
$meta = $this->metaData->firstWhere('key', 'virtual');
return ! is_null($meta) && (bool) $meta->value;
} | Determine if the stockable model is virtual. | isVirtual | php | conedevelopment/bazar | src/Traits/InteractsWithStock.php | https://github.com/conedevelopment/bazar/blob/master/src/Traits/InteractsWithStock.php | MIT |
public function isPhysical(): bool
{
return ! $this->isVirtual();
} | Determine if the stockable model is physical. | isPhysical | php | conedevelopment/bazar | src/Traits/InteractsWithStock.php | https://github.com/conedevelopment/bazar/blob/master/src/Traits/InteractsWithStock.php | MIT |
public function isDownloadable(): bool
{
$meta = $this->metaData->firstWhere('key', 'downloadable');
return ! is_null($meta) && (bool) $meta->value;
} | Determine if the stockable model is downloadable. | isDownloadable | php | conedevelopment/bazar | src/Traits/InteractsWithStock.php | https://github.com/conedevelopment/bazar/blob/master/src/Traits/InteractsWithStock.php | MIT |
public function tracksQuantity(): bool
{
$meta = $this->metaData->firstWhere('key', 'quantity');
return ! is_null($meta) && ! empty($meta->value);
} | Determine if the stockable model tracks quantity. | tracksQuantity | php | conedevelopment/bazar | src/Traits/InteractsWithStock.php | https://github.com/conedevelopment/bazar/blob/master/src/Traits/InteractsWithStock.php | MIT |
public function isAvailable(float $quantity = 1): bool
{
if (! $this->tracksQuantity()) {
return true;
}
$stock = $this->metaData->firstWhere('key', 'quantity')?->value ?: 0;
return min($stock, $quantity) > 0 && $stock >= $quantity;
} | Determine if the stockable model is available. | isAvailable | php | conedevelopment/bazar | src/Traits/InteractsWithStock.php | https://github.com/conedevelopment/bazar/blob/master/src/Traits/InteractsWithStock.php | MIT |
public function incrementQuantity(float $quantity = 1): void
{
if ($this->tracksQuantity()) {
$meta = $this->metaData->firstWhere('key', 'quantity')
?: $this->metaData()->make(['key' => 'quantity', 'value' => 0]);
$meta->value = ((float) $meta->value) + $quantity;
$meta->save();
}
} | Increment the quantity by the given value. | incrementQuantity | php | conedevelopment/bazar | src/Traits/InteractsWithStock.php | https://github.com/conedevelopment/bazar/blob/master/src/Traits/InteractsWithStock.php | MIT |
public function decrementQuantity(float $quantity = 1): void
{
if ($this->tracksQuantity()) {
$meta = $this->metaData->firstWhere('key', 'quantity')
?: $this->metaData()->make(['key' => 'quantity', 'value' => 0]);
$meta->value = max(((float) $meta->value) - $quantity, 0);
$meta->save();
}
} | Decrement the quantity by the given value. | decrementQuantity | php | conedevelopment/bazar | src/Traits/InteractsWithStock.php | https://github.com/conedevelopment/bazar/blob/master/src/Traits/InteractsWithStock.php | MIT |
public function taxes(): MorphToMany
{
return $this->morphToMany(TaxRate::getProxiedClass(), 'taxable', 'bazar_taxes')
->as('tax')
->using(Tax::getProxiedClass())
->withPivot('value')
->withTimestamps();
} | Get the taxes for the model. | taxes | php | conedevelopment/bazar | src/Traits/InteractsWithTaxes.php | https://github.com/conedevelopment/bazar/blob/master/src/Traits/InteractsWithTaxes.php | MIT |
protected function tax(): Attribute
{
return new Attribute(
get: fn (): float => $this->getTax()
);
} | Get the tax total.
@return \Illuminate\Database\Eloquent\Casts\Attribute<string, never> | tax | php | conedevelopment/bazar | src/Traits/InteractsWithTaxes.php | https://github.com/conedevelopment/bazar/blob/master/src/Traits/InteractsWithTaxes.php | MIT |
protected function formattedTax(): Attribute
{
return new Attribute(
get: fn (): string => $this->getFormattedTax()
);
} | Get the formatted tax attribute.
@return \Illuminate\Database\Eloquent\Casts\Attribute<string, never> | formattedTax | php | conedevelopment/bazar | src/Traits/InteractsWithTaxes.php | https://github.com/conedevelopment/bazar/blob/master/src/Traits/InteractsWithTaxes.php | MIT |
protected function taxTotal(): Attribute
{
return new Attribute(
get: fn (): float => $this->getTaxTotal()
);
} | Get the tax total.
@return \Illuminate\Database\Eloquent\Casts\Attribute<string, never> | taxTotal | php | conedevelopment/bazar | src/Traits/InteractsWithTaxes.php | https://github.com/conedevelopment/bazar/blob/master/src/Traits/InteractsWithTaxes.php | MIT |
protected function formattedTaxTotal(): Attribute
{
return new Attribute(
get: fn (): string => $this->getFormattedTaxTotal()
);
} | Get the formatted tax attribute.
@return \Illuminate\Database\Eloquent\Casts\Attribute<string, never> | formattedTaxTotal | php | conedevelopment/bazar | src/Traits/InteractsWithTaxes.php | https://github.com/conedevelopment/bazar/blob/master/src/Traits/InteractsWithTaxes.php | MIT |
public function __construct(array $attributes)
{
if (isset($attributes['title'])) {
$this->setTitle($attributes['title']);
}
if (isset($attributes['text'])) {
$this->setText($attributes['text']);
}
if (isset($attributes['ok_text'])) {
$this->setOkText($attributes['ok_text']);
}
if (isset($attributes['dismiss_text'])) {
$this->setDismissText($attributes['dismiss_text']);
}
} | Instantiate a new ActionConfirmation.
@param array $attributes
@return void | __construct | php | maknz/slack | src/ActionConfirmation.php | https://github.com/maknz/slack/blob/master/src/ActionConfirmation.php | BSD-2-Clause |
public function toArray()
{
return [
'title' => $this->getTitle(),
'text' => $this->getText(),
'ok_text' => $this->getOkText(),
'dismiss_text' => $this->getDismissText(),
];
} | Get the array representation of this action confirmation.
@return array | toArray | php | maknz/slack | src/ActionConfirmation.php | https://github.com/maknz/slack/blob/master/src/ActionConfirmation.php | BSD-2-Clause |
public function __construct(array $attributes)
{
if (isset($attributes['fallback'])) {
$this->setFallback($attributes['fallback']);
}
if (isset($attributes['text'])) {
$this->setText($attributes['text']);
}
if (isset($attributes['image_url'])) {
$this->setImageUrl($attributes['image_url']);
}
if (isset($attributes['thumb_url'])) {
$this->setThumbUrl($attributes['thumb_url']);
}
if (isset($attributes['pretext'])) {
$this->setPretext($attributes['pretext']);
}
if (isset($attributes['color'])) {
$this->setColor($attributes['color']);
}
if (isset($attributes['footer'])) {
$this->setFooter($attributes['footer']);
}
if (isset($attributes['footer_icon'])) {
$this->setFooterIcon($attributes['footer_icon']);
}
if (isset($attributes['timestamp'])) {
$this->setTimestamp($attributes['timestamp']);
}
if (isset($attributes['fields'])) {
$this->setFields($attributes['fields']);
}
if (isset($attributes['mrkdwn_in'])) {
$this->setMarkdownFields($attributes['mrkdwn_in']);
}
if (isset($attributes['title'])) {
$this->setTitle($attributes['title']);
}
if (isset($attributes['title_link'])) {
$this->setTitleLink($attributes['title_link']);
}
if (isset($attributes['author_name'])) {
$this->setAuthorName($attributes['author_name']);
}
if (isset($attributes['author_link'])) {
$this->setAuthorLink($attributes['author_link']);
}
if (isset($attributes['author_icon'])) {
$this->setAuthorIcon($attributes['author_icon']);
}
if (isset($attributes['actions'])) {
$this->setActions($attributes['actions']);
}
} | Instantiate a new Attachment.
@param array $attributes
@return void | __construct | php | maknz/slack | src/Attachment.php | https://github.com/maknz/slack/blob/master/src/Attachment.php | BSD-2-Clause |
public function getFallback()
{
return $this->fallback;
} | Get the fallback text.
@return string | getFallback | php | maknz/slack | src/Attachment.php | https://github.com/maknz/slack/blob/master/src/Attachment.php | BSD-2-Clause |
public function setFallback($fallback)
{
$this->fallback = $fallback;
return $this;
} | Set the fallback text.
@param string $fallback
@return $this | setFallback | php | maknz/slack | src/Attachment.php | https://github.com/maknz/slack/blob/master/src/Attachment.php | BSD-2-Clause |
public function getText()
{
return $this->text;
} | Get the optional text to appear within the attachment.
@return string | getText | php | maknz/slack | src/Attachment.php | https://github.com/maknz/slack/blob/master/src/Attachment.php | BSD-2-Clause |
public function setText($text)
{
$this->text = $text;
return $this;
} | Set the optional text to appear within the attachment.
@param string $text
@return $this | setText | php | maknz/slack | src/Attachment.php | https://github.com/maknz/slack/blob/master/src/Attachment.php | BSD-2-Clause |
public function getImageUrl()
{
return $this->image_url;
} | Get the optional image to appear within the attachment.
@return string | getImageUrl | php | maknz/slack | src/Attachment.php | https://github.com/maknz/slack/blob/master/src/Attachment.php | BSD-2-Clause |
public function setImageUrl($image_url)
{
$this->image_url = $image_url;
return $this;
} | Set the optional image to appear within the attachment.
@param string $image_url
@return $this | setImageUrl | php | maknz/slack | src/Attachment.php | https://github.com/maknz/slack/blob/master/src/Attachment.php | BSD-2-Clause |
public function getThumbUrl()
{
return $this->thumb_url;
} | Get the optional thumbnail to appear within the attachment.
@return string | getThumbUrl | php | maknz/slack | src/Attachment.php | https://github.com/maknz/slack/blob/master/src/Attachment.php | BSD-2-Clause |
public function setThumbUrl($thumb_url)
{
$this->thumb_url = $thumb_url;
return $this;
} | Set the optional thumbnail to appear within the attachment.
@param string $thumb_url
@return $this | setThumbUrl | php | maknz/slack | src/Attachment.php | https://github.com/maknz/slack/blob/master/src/Attachment.php | BSD-2-Clause |
public function getPretext()
{
return $this->pretext;
} | Get the text that should appear above the formatted data.
@return string | getPretext | php | maknz/slack | src/Attachment.php | https://github.com/maknz/slack/blob/master/src/Attachment.php | BSD-2-Clause |
public function setPretext($pretext)
{
$this->pretext = $pretext;
return $this;
} | Set the text that should appear above the formatted data.
@param string $pretext
@return $this | setPretext | php | maknz/slack | src/Attachment.php | https://github.com/maknz/slack/blob/master/src/Attachment.php | BSD-2-Clause |
public function getColor()
{
return $this->color;
} | Get the color to use for the attachment.
@return string | getColor | php | maknz/slack | src/Attachment.php | https://github.com/maknz/slack/blob/master/src/Attachment.php | BSD-2-Clause |
public function setColor($color)
{
$this->color = $color;
return $this;
} | Set the color to use for the attachment.
@param string $color
@return $this | setColor | php | maknz/slack | src/Attachment.php | https://github.com/maknz/slack/blob/master/src/Attachment.php | BSD-2-Clause |
public function getFooter()
{
return $this->footer;
} | Get the footer to use for the attachment.
@return string | getFooter | php | maknz/slack | src/Attachment.php | https://github.com/maknz/slack/blob/master/src/Attachment.php | BSD-2-Clause |
public function setFooter($footer)
{
$this->footer = $footer;
return $this;
} | Set the footer text to use for the attachment.
@param string $footer
@return $this | setFooter | php | maknz/slack | src/Attachment.php | https://github.com/maknz/slack/blob/master/src/Attachment.php | BSD-2-Clause |
public function getFooterIcon()
{
return $this->footer_icon;
} | Get the footer icon to use for the attachment.
@return string | getFooterIcon | php | maknz/slack | src/Attachment.php | https://github.com/maknz/slack/blob/master/src/Attachment.php | BSD-2-Clause |
public function setFooterIcon($footerIcon)
{
$this->footer_icon = $footerIcon;
return $this;
} | Set the footer icon to use for the attachment.
@param string $footerIcon
@return $this | setFooterIcon | php | maknz/slack | src/Attachment.php | https://github.com/maknz/slack/blob/master/src/Attachment.php | BSD-2-Clause |
public function getTimestamp()
{
return $this->timestamp;
} | Get the timestamp to use for the attachment.
@return \DateTime | getTimestamp | php | maknz/slack | src/Attachment.php | https://github.com/maknz/slack/blob/master/src/Attachment.php | BSD-2-Clause |
public function setTimestamp($timestamp)
{
$this->timestamp = $timestamp;
return $this;
} | Set the timestamp to use for the attachment.
@param \DateTime $timestamp
@return $this | setTimestamp | php | maknz/slack | src/Attachment.php | https://github.com/maknz/slack/blob/master/src/Attachment.php | BSD-2-Clause |
public function getTitle()
{
return $this->title;
} | Get the title to use for the attachment.
@return string | getTitle | php | maknz/slack | src/Attachment.php | https://github.com/maknz/slack/blob/master/src/Attachment.php | BSD-2-Clause |
public function setTitle($title)
{
$this->title = $title;
return $this;
} | Set the title to use for the attachment.
@param string $title
@return $this | setTitle | php | maknz/slack | src/Attachment.php | https://github.com/maknz/slack/blob/master/src/Attachment.php | BSD-2-Clause |
public function getTitleLink()
{
return $this->title_link;
} | Get the title link to use for the attachment.
@return string | getTitleLink | php | maknz/slack | src/Attachment.php | https://github.com/maknz/slack/blob/master/src/Attachment.php | BSD-2-Clause |
public function setTitleLink($title_link)
{
$this->title_link = $title_link;
return $this;
} | Set the title link to use for the attachment.
@param string $title_link
@return $this | setTitleLink | php | maknz/slack | src/Attachment.php | https://github.com/maknz/slack/blob/master/src/Attachment.php | BSD-2-Clause |
public function getAuthorName()
{
return $this->author_name;
} | Get the author name to use for the attachment.
@return string | getAuthorName | php | maknz/slack | src/Attachment.php | https://github.com/maknz/slack/blob/master/src/Attachment.php | BSD-2-Clause |
public function setAuthorName($author_name)
{
$this->author_name = $author_name;
return $this;
} | Set the author name to use for the attachment.
@param string $author_name
@return $this | setAuthorName | php | maknz/slack | src/Attachment.php | https://github.com/maknz/slack/blob/master/src/Attachment.php | BSD-2-Clause |
public function getAuthorLink()
{
return $this->author_link;
} | Get the author link to use for the attachment.
@return string | getAuthorLink | php | maknz/slack | src/Attachment.php | https://github.com/maknz/slack/blob/master/src/Attachment.php | BSD-2-Clause |
public function setAuthorLink($author_link)
{
$this->author_link = $author_link;
return $this;
} | Set the auhtor link to use for the attachment.
@param string $author_link
@return $this | setAuthorLink | php | maknz/slack | src/Attachment.php | https://github.com/maknz/slack/blob/master/src/Attachment.php | BSD-2-Clause |
public function getAuthorIcon()
{
return $this->author_icon;
} | Get the author icon to use for the attachment.
@return string | getAuthorIcon | php | maknz/slack | src/Attachment.php | https://github.com/maknz/slack/blob/master/src/Attachment.php | BSD-2-Clause |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.