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
protected function resolved(Request $request, Cart $cart): void { parent::resolved($request, $cart); $request->session()->put('cart_id', $cart->getKey()); }
The callback after the cart instance is resolved.
resolved
php
conedevelopment/bazar
src/Cart/SessionDriver.php
https://github.com/conedevelopment/bazar/blob/master/src/Cart/SessionDriver.php
MIT
public function valueToClass(string $value): string { return match ($value) { Order::PENDING, Order::ON_HOLD => 'status--warning', Order::CANCELLED, Order::FAILED => 'status--danger', Order::FULFILLED => 'status--success', Order::IN_PROGRESS => 'status--info', default => 'status--info', }; }
Convert the value to a class name.
valueToClass
php
conedevelopment/bazar
src/Fields/OrderStatus.php
https://github.com/conedevelopment/bazar/blob/master/src/Fields/OrderStatus.php
MIT
public function getTransactionUrl(Transaction $transaction): ?string { return null; }
Get the URL of the transaction.
getTransactionUrl
php
conedevelopment/bazar
src/Gateway/Driver.php
https://github.com/conedevelopment/bazar/blob/master/src/Gateway/Driver.php
MIT
public function getCaptureUrl(Order $order): string { return URL::route('bazar.gateway.capture', [ 'driver' => $this->name, 'order' => $order->uuid, ]); }
Get the URL for the payment capture.
getCaptureUrl
php
conedevelopment/bazar
src/Gateway/Driver.php
https://github.com/conedevelopment/bazar/blob/master/src/Gateway/Driver.php
MIT
public function resolveOrder(string $id): Order { return Order::proxy()->newQuery()->where('bazar_orders.uuid', $id)->firstOrFail(); }
Resolve the order by the given UUID.
resolveOrder
php
conedevelopment/bazar
src/Gateway/Driver.php
https://github.com/conedevelopment/bazar/blob/master/src/Gateway/Driver.php
MIT
public function resolveOrderForCapture(Request $request): Order { return $this->resolveOrder($request->input('order', '')); }
Resolve the order model for payment capture.
resolveOrderForCapture
php
conedevelopment/bazar
src/Gateway/Driver.php
https://github.com/conedevelopment/bazar/blob/master/src/Gateway/Driver.php
MIT
public function resolveOrderForNotification(Request $request): Order { return $this->resolveOrder($request->input('order', '')); }
Resolve the order model for notification.
resolveOrderForNotification
php
conedevelopment/bazar
src/Gateway/Driver.php
https://github.com/conedevelopment/bazar/blob/master/src/Gateway/Driver.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/Gateway/Manager.php
https://github.com/conedevelopment/bazar/blob/master/src/Gateway/Manager.php
MIT
public function toArray(): array { return array_merge($this->data, [ 'url' => $this->url, ]); }
Convert the response to an array.
toArray
php
conedevelopment/bazar
src/Gateway/Response.php
https://github.com/conedevelopment/bazar/blob/master/src/Gateway/Response.php
MIT
public function toResponse($request): BaseResponse { if (! is_null($this->responseResolver)) { return call_user_func_array($this->responseResolver, [$this->url, $this->data]); } elseif ($request->wantsJson()) { return new JsonResponse($this->toArray()); } return new RedirectResponse($this->url); }
Convert the response to an HTTP response.
toResponse
php
conedevelopment/bazar
src/Gateway/Response.php
https://github.com/conedevelopment/bazar/blob/master/src/Gateway/Response.php
MIT
protected static function newFactory(): AddressFactory { return AddressFactory::new(); }
Create a new factory instance for the model.
newFactory
php
conedevelopment/bazar
src/Models/Address.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Address.php
MIT
public function addressable(): MorphTo { return $this->morphTo(); }
Get the addressable model for the address.
addressable
php
conedevelopment/bazar
src/Models/Address.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Address.php
MIT
protected function alias(): Attribute { return new Attribute( get: function (?string $value): ?string { return $this->exists ? ($value ?: $this->name) : $value; } ); }
Get the alias attribute. @return \Illuminate\Database\Eloquent\Casts\Attribute<string|null, never>
alias
php
conedevelopment/bazar
src/Models/Address.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Address.php
MIT
protected function name(): Attribute { return new Attribute( get: function (mixed $value, array $attributes): string { return trim(sprintf('%s %s', $attributes['first_name'], $attributes['last_name'])); } ); }
Get the name attribute. @return \Illuminate\Database\Eloquent\Casts\Attribute<string, never>
name
php
conedevelopment/bazar
src/Models/Address.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Address.php
MIT
protected static function booted(): void { static::creating(static function (self $cart): void { $cart->setAttribute('currency', $cart->currency ?: Bazar::getCurrency()); }); }
The "booted" method of the model.
booted
php
conedevelopment/bazar
src/Models/Cart.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Cart.php
MIT
protected static function newFactory(): CartFactory { return CartFactory::new(); }
Create a new factory instance for the model.
newFactory
php
conedevelopment/bazar
src/Models/Cart.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Cart.php
MIT
public function order(): BelongsTo { return $this->belongsTo(Order::getProxiedClass()) ->withDefault(function (Order $order): Order { return $order->fill($this->toArray()); }); }
Get the order for the cart. @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\Cone\Bazar\Models\Order, \Cone\Bazar\Models\Cart>
order
php
conedevelopment/bazar
src/Models/Cart.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Cart.php
MIT
public function address(): MorphOne { return $this->morphOne(Address::getProxiedClass(), 'addressable') ->withDefault(function (Address $address): Address { return $address->fill($this->user?->address?->toArray() ?: []); }); }
Get the address for the model.
address
php
conedevelopment/bazar
src/Models/Cart.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Cart.php
MIT
public function scopeLocked(Builder $query): Builder { return $query->where($query->qualifyColumn('locked'), true); }
Scope a query to only include the locked carts.
scopeLocked
php
conedevelopment/bazar
src/Models/Cart.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Cart.php
MIT
public function scopeUnlocked(Builder $query): Builder { return $query->where($query->qualifyColumn('locked'), false); }
Scope a query to only include the unlocked carts.
scopeUnlocked
php
conedevelopment/bazar
src/Models/Cart.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Cart.php
MIT
public function scopeExpired(Builder $query): Builder { return $query->whereNull($query->qualifyColumn('user_id')) ->where($query->qualifyColumn('updated_at'), '<', Date::now()->subDays(3)); }
Scope a query to only include the expired carts.
scopeExpired
php
conedevelopment/bazar
src/Models/Cart.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Cart.php
MIT
public function toOrder(): Order { $this->getLineItems()->each(function (Item $item): void { if (! $item->buyable->buyable($this->order)) { throw new CartException(sprintf('Unable to add [%s] item to the order.', get_class($item->buyable))); } }); $this->order->user()->associate($this->user)->save(); if ($this->order_id !== $this->order->getKey()) { $this->order()->associate($this->order)->save(); } $this->order->items()->delete(); $this->order->items()->createMany($this->items->toArray()); $this->order->address->fill($this->address->toArray())->save(); if ($this->order->needsShipping()) { $this->order->shipping->fill($this->shipping->toArray())->save(); $this->order->shipping->address->fill($this->shipping->address->toArray())->save(); } $this->order->calculateTax(); return $this->order; }
Convert the cart to a new order.
toOrder
php
conedevelopment/bazar
src/Models/Cart.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Cart.php
MIT
protected static function newFactory(): CategoryFactory { return CategoryFactory::new(); }
Create a new factory instance for the model.
newFactory
php
conedevelopment/bazar
src/Models/Category.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Category.php
MIT
public function parent(): BelongsTo { return $this->belongsTo(static::class, 'parent_id'); }
Get the parent for the category.
parent
php
conedevelopment/bazar
src/Models/Category.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Category.php
MIT
public function products(): BelongsToMany { return $this->belongsToMany(Product::getProxiedClass(), 'bazar_category_product'); }
Get the products for the category.
products
php
conedevelopment/bazar
src/Models/Category.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Category.php
MIT
protected static function newFactory(): ItemFactory { return ItemFactory::new(); }
Create a new factory instance for the model.
newFactory
php
conedevelopment/bazar
src/Models/Item.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Item.php
MIT
public function buyable(): MorphTo { return $this->morphTo(); }
Get the buyable model for the item.
buyable
php
conedevelopment/bazar
src/Models/Item.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Item.php
MIT
public function checkoutable(): MorphTo { return $this->morphTo()->withDefault(); }
Get the checkoutable model for the item.
checkoutable
php
conedevelopment/bazar
src/Models/Item.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Item.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, never>
formattedPrice
php
conedevelopment/bazar
src/Models/Item.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Item.php
MIT
protected function formattedGrossPrice(): Attribute { return new Attribute( get: fn (): string => $this->getFormattedGrossPrice(), ); }
Get the formatted gross price attribute. @return \Illuminate\Database\Eloquent\Casts\Attribute<string, never>
formattedGrossPrice
php
conedevelopment/bazar
src/Models/Item.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Item.php
MIT
protected function total(): Attribute { return new Attribute( get: fn (): float => $this->getTotal() ); }
Get the total attribute. @return \Illuminate\Database\Eloquent\Casts\Attribute<float, never>
total
php
conedevelopment/bazar
src/Models/Item.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Item.php
MIT
protected function formattedTotal(): Attribute { return new Attribute( get: fn (): string => $this->getFormattedTotal() ); }
Get the formatted total attribute. @return \Illuminate\Database\Eloquent\Casts\Attribute<string, never>
formattedTotal
php
conedevelopment/bazar
src/Models/Item.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Item.php
MIT
protected function subtotal(): Attribute { return new Attribute( get: fn (): float => $this->getSubtotal() ); }
Get the subtotal attribute. @return \Illuminate\Database\Eloquent\Casts\Attribute<float, never>
subtotal
php
conedevelopment/bazar
src/Models/Item.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Item.php
MIT
protected function formattedSubtotal(): Attribute { return new Attribute( get: fn (): string => $this->getFormattedSubtotal() ); }
Get the formatted subtotal attribute. @return \Illuminate\Database\Eloquent\Casts\Attribute<string, never>
formattedSubtotal
php
conedevelopment/bazar
src/Models/Item.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Item.php
MIT
public function isLineItem(): bool { return $this->buyable instanceof Buyable; }
Determine if the item is a line item.
isLineItem
php
conedevelopment/bazar
src/Models/Item.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Item.php
MIT
public function isFee(): bool { return ! $this->isLineItem(); }
Determine if the item is a fee.
isFee
php
conedevelopment/bazar
src/Models/Item.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Item.php
MIT
protected static function newFactory(): OrderFactory { return OrderFactory::new(); }
Create a new factory instance for the model.
newFactory
php
conedevelopment/bazar
src/Models/Order.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Order.php
MIT
public function cart(): HasOne { return $this->hasOne(Cart::getProxiedClass()); }
Get the cart for the order.
cart
php
conedevelopment/bazar
src/Models/Order.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Order.php
MIT
public function transactions(): HasMany { return $this->hasMany(Transaction::getProxiedClass()); }
Get the transactions for the order.
transactions
php
conedevelopment/bazar
src/Models/Order.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Order.php
MIT
public function transaction(): HasOne { return $this->transactions()->one()->ofMany( ['id' => 'MIN'], static function (Builder $query): Builder { return $query->payment(); } ); }
Get the base transaction for the order.
transaction
php
conedevelopment/bazar
src/Models/Order.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Order.php
MIT
protected function payments(): Attribute { return new Attribute( get: function (): Collection { return $this->transactions->where('type', Transaction::PAYMENT); } ); }
Get the payments attribute. @return \Illuminate\Database\Eloquent\Casts\Attribute<\Illuminate\Support\Collection, never>
payments
php
conedevelopment/bazar
src/Models/Order.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Order.php
MIT
protected function refunds(): Attribute { return new Attribute( get: function (): Collection { return $this->transactions->where('type', Transaction::REFUND); } ); }
Get the refunds attribute. @return \Illuminate\Database\Eloquent\Casts\Attribute<\Illuminate\Support\Collection, never>
refunds
php
conedevelopment/bazar
src/Models/Order.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Order.php
MIT
protected function statusName(): Attribute { return new Attribute( get: static function (mixed $value, array $attributes): string { return static::getStatuses()[$attributes['status']] ?? $attributes['status']; } ); }
Get the status name attribute. @return \Illuminate\Database\Eloquent\Casts\Attribute<string, never>
statusName
php
conedevelopment/bazar
src/Models/Order.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Order.php
MIT
protected function paymentStatus(): Attribute { return new Attribute( get: function (): string { return match (true) { $this->refunded() => __('Refunded'), $this->partiallyRefunded() => __('Partially Refunded'), $this->paid() => __('Paid'), $this->partiallyPaid() => __('Partially Paid'), default => __('Pending Payment'), }; } ); }
Get the payment status name attribute. @return \Illuminate\Database\Eloquent\Casts\Attribute<string, never>
paymentStatus
php
conedevelopment/bazar
src/Models/Order.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Order.php
MIT
public function uniqueIds(): array { return ['uuid']; }
Get the columns that should receive a unique identifier.
uniqueIds
php
conedevelopment/bazar
src/Models/Order.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Order.php
MIT
public function pay(?float $amount = null, ?string $driver = null, array $attributes = []): Transaction { if (! $this->payable()) { throw new TransactionFailedException("Order #{$this->getKey()} is fully paid."); } $transaction = $this->transactions()->create(array_replace($attributes, [ 'type' => Transaction::PAYMENT, 'driver' => $driver ?: Gateway::getDefaultDriver(), 'amount' => is_null($amount) ? $this->getTotalPayable() : min($amount, $this->getTotalPayable()), ])); $this->transactions->push($transaction); return $transaction; }
Create a payment transaction for the order.
pay
php
conedevelopment/bazar
src/Models/Order.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Order.php
MIT
public function refund(?float $amount = null, ?string $driver = null, array $attributes = []): Transaction { if (! $this->refundable()) { throw new TransactionFailedException("Order #{$this->getKey()} is fully refunded."); } $transaction = $this->transactions()->create(array_replace($attributes, [ 'type' => Transaction::REFUND, 'driver' => $driver ?: Gateway::getDefaultDriver(), 'amount' => is_null($amount) ? $this->getTotalRefundable() : min($amount, $this->getTotalRefundable()), ])); $this->transactions->push($transaction); return $transaction; }
Create a refund transaction for the order.
refund
php
conedevelopment/bazar
src/Models/Order.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Order.php
MIT
public function paid(): bool { return $this->payments->filter->completed()->isNotEmpty() && $this->getTotal() <= $this->getTotalPaid(); }
Determine if the order is fully paid.
paid
php
conedevelopment/bazar
src/Models/Order.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Order.php
MIT
public function partiallyPaid(): bool { return $this->payments->filter->completed()->isNotEmpty() && $this->getTotal() > $this->getTotalPaid(); }
Determine if the order is partially paid.
partiallyPaid
php
conedevelopment/bazar
src/Models/Order.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Order.php
MIT
public function payable(): bool { return in_array($this->status, [static::ON_HOLD, static::PENDING, static::CANCELLED]) && $this->getTotalPayable() > 0 && ! $this->paid(); }
Determine if the order is payable.
payable
php
conedevelopment/bazar
src/Models/Order.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Order.php
MIT
public function refunded(): bool { return $this->refunds->filter->completed()->isNotEmpty() && $this->getTotalPaid() <= $this->getTotalRefunded(); }
Determine if the order is fully refunded.
refunded
php
conedevelopment/bazar
src/Models/Order.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Order.php
MIT
public function refundable(): bool { return $this->getTotalRefundable() > 0 && ! $this->refunded(); }
Determine if the order is refundable.
refundable
php
conedevelopment/bazar
src/Models/Order.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Order.php
MIT
public function partiallyRefunded(): bool { return $this->refunds->filter->completed()->isNotEmpty() && $this->getTotalPaid() > $this->getTotalRefunded(); }
Determine if the orderis partially refunded.
partiallyRefunded
php
conedevelopment/bazar
src/Models/Order.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Order.php
MIT
public function markAs(string $status): void { if ($this->status !== $status) { $from = $this->status; $this->setAttribute('status', $status)->save(); OrderStatusChanged::dispatch($this, $status, $from); } }
Set the status by the given value.
markAs
php
conedevelopment/bazar
src/Models/Order.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Order.php
MIT
public function scopeStatus(Builder $query, string $status): Builder { return $query->where($query->qualifyColumn('status'), $status); }
Scope a query to only include orders with the given status.
scopeStatus
php
conedevelopment/bazar
src/Models/Order.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Order.php
MIT
public function scopeUser(Builder $query, int $value): Builder { return $query->whereHas('user', static function (Builder $query) use ($value): Builder { return $query->whereKey($value); }); }
Scope the query to the given user.
scopeUser
php
conedevelopment/bazar
src/Models/Order.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Order.php
MIT
public static function formatCurrency(string $currency, Closure $callback): void { static::$formatters[$currency] = $callback; }
Register a formatter to the given currency.
formatCurrency
php
conedevelopment/bazar
src/Models/Price.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Price.php
MIT
protected function currency(): Attribute { return new Attribute( get: static function (mixed $value, array $attributes): string { return Str::before(str_replace('price_', '', $attributes['key']), '_'); } ); }
Get the currency attribute. @return \Illuminate\Database\Eloquent\Casts\Attribute<string, never>
currency
php
conedevelopment/bazar
src/Models/Price.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Price.php
MIT
protected function symbol(): Attribute { return new Attribute( get: static function (mixed $value, array $attributes): string { return Bazar::getCurrencies()[$attributes['currency']] ?? $attributes['currency']; } ); }
Get the currency symbol attribute. @return \Illuminate\Database\Eloquent\Casts\Attribute<string, never>
symbol
php
conedevelopment/bazar
src/Models/Price.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Price.php
MIT
protected static function newFactory(): ProductFactory { return ProductFactory::new(); }
Create a new factory instance for the model.
newFactory
php
conedevelopment/bazar
src/Models/Product.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Product.php
MIT
public function categories(): BelongsToMany { return $this->belongsToMany(Category::getProxiedClass(), 'bazar_category_product'); }
Get the categories for the product.
categories
php
conedevelopment/bazar
src/Models/Product.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Product.php
MIT
public function variants(): HasMany { return $this->hasMany(Variant::getProxiedClass()); }
Get the variants for the product.
variants
php
conedevelopment/bazar
src/Models/Product.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Product.php
MIT
public function taxRates(): MorphToMany { return $this->morphToMany(TaxRate::getProxiedClass(), 'buyable', 'bazar_buyable_tax_rate'); }
Get the tax rates for the product.
taxRates
php
conedevelopment/bazar
src/Models/Product.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Product.php
MIT
public function buyable(Checkoutable $model): bool { return true; }
Determine whether the buyable object is available for the checkoutable instance.
buyable
php
conedevelopment/bazar
src/Models/Product.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Product.php
MIT
public function scopeOutOfStock(Builder $query): Builder { return $query->whereHas('metaData', static function (Builder $query): Builder { return $query->where($query->qualifyColumn('key'), 'quantity') ->where($query->qualifyColumn('value'), 0); }); }
Scope the query only to the models that are out of stock.
scopeOutOfStock
php
conedevelopment/bazar
src/Models/Product.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Product.php
MIT
public function scopeInStock(Builder $query): Builder { return $query->whereHas('metaData', static function (Builder $query): Builder { return $query->where($query->qualifyColumn('key'), 'quantity') ->where($query->qualifyColumn('value'), '>', 0); }); }
Scope the query only to the models that are in stock.
scopeInStock
php
conedevelopment/bazar
src/Models/Product.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Product.php
MIT
public function toVariant(array $variation): ?Variant { return $this->variants() ->getQuery() ->whereHas( 'propertyValues', static function (Builder $query) use ($variation): Builder { return $query->whereIn($query->qualifyColumn('value'), $variation) ->whereHas('property', static function (Builder $query) use ($variation): Builder { return $query->whereIn($query->qualifyColumn('slug'), array_keys($variation)); }); }, '=', function (QueryBuilder $query): QueryBuilder { return $query->selectRaw('count(*)') ->from('bazar_buyable_property_value') ->whereIn('bazar_buyable_property_value.buyable_id', $this->variants()->select('bazar_variants.id')) ->where('bazar_buyable_property_value.buyable_type', Variant::getProxiedClass()); } ) ->first(); }
Get the variant of the given option.
toVariant
php
conedevelopment/bazar
src/Models/Product.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Product.php
MIT
public function toItem(Checkoutable $checkoutable, array $attributes = []): Item { if ($variant = $this->toVariant($attributes['properties'] ?? [])) { return $variant->toItem($checkoutable, $attributes); } 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/Product.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Product.php
MIT
protected static function booted(): void { static::deleting(static function (self $property): void { $property->values()->delete(); }); }
The "booted" method of the model.
booted
php
conedevelopment/bazar
src/Models/Property.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Property.php
MIT
protected static function newFactory(): PropertyFactory { return PropertyFactory::new(); }
Create a new factory instance for the model.
newFactory
php
conedevelopment/bazar
src/Models/Property.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Property.php
MIT
public function values(): HasMany { return $this->hasMany(PropertyValue::getProxiedClass()); }
Get the values for the property.
values
php
conedevelopment/bazar
src/Models/Property.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Property.php
MIT
protected static function newFactory(): PropertyValueFactory { return PropertyValueFactory::new(); }
Create a new factory instance for the model.
newFactory
php
conedevelopment/bazar
src/Models/PropertyValue.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/PropertyValue.php
MIT
public function property(): BelongsTo { return $this->belongsTo(Property::getProxiedClass()); }
Get the property for the property value.
property
php
conedevelopment/bazar
src/Models/PropertyValue.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/PropertyValue.php
MIT
protected static function booted(): void { static::creating(static function (self $shipping): void { $shipping->driver = $shipping->driver ?: Manager::getDefaultDriver(); }); }
The "booted" method of the model.
booted
php
conedevelopment/bazar
src/Models/Shipping.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Shipping.php
MIT
protected static function newFactory(): ShippingFactory { return ShippingFactory::new(); }
Create a new factory instance for the model.
newFactory
php
conedevelopment/bazar
src/Models/Shipping.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Shipping.php
MIT
public function shippable(): MorphTo { return $this->morphTo()->withDefault(static function (): Cart { return Cart::proxy()->newInstance(); }); }
Get the shippable model for the shipping.
shippable
php
conedevelopment/bazar
src/Models/Shipping.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Shipping.php
MIT
protected function driver(): Attribute { return new Attribute( get: static function (?string $value = null): string { return $value ?: Manager::getDefaultDriver(); } ); }
Get the driver attribute. @return \Illuminate\Database\Eloquent\Casts\Attribute<string, never>
driver
php
conedevelopment/bazar
src/Models/Shipping.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Shipping.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/Models/Shipping.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Shipping.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/Models/Shipping.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Shipping.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/Models/Shipping.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Shipping.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/Models/Shipping.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Shipping.php
MIT
protected function driverName(): Attribute { return new Attribute( get: static function (mixed $value, array $attributes): string { try { return Manager::driver($attributes['driver'])->getName(); } catch (Throwable $exception) { return $attributes['driver']; } } ); }
Get the name of the shipping method. @return \Illuminate\Database\Eloquent\Casts\Attribute<string, never>
driverName
php
conedevelopment/bazar
src/Models/Shipping.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Shipping.php
MIT
protected static function newFactory(): TaxRateFactory { return TaxRateFactory::new(); }
Create a new factory instance for the model.
newFactory
php
conedevelopment/bazar
src/Models/TaxRate.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/TaxRate.php
MIT
public function calculate(Taxable $taxable): float { return round($taxable->getTaxBase() * $this->rate, 2); }
Calculate the tax for the taxable model.
calculate
php
conedevelopment/bazar
src/Models/TaxRate.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/TaxRate.php
MIT
public function scopeApplicableForShipping(Builder $query): Builder { return $query->where($query->qualifyColumn('shipping'), true); }
Scope the query for the results that are applicable for shipping.
scopeApplicableForShipping
php
conedevelopment/bazar
src/Models/TaxRate.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/TaxRate.php
MIT
protected static function newFactory(): TransactionFactory { return TransactionFactory::new(); }
Create a new factory instance for the model.
newFactory
php
conedevelopment/bazar
src/Models/Transaction.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Transaction.php
MIT
public function order(): BelongsTo { return $this->belongsTo(Order::getProxiedClass()); }
Get the order for the transaction. @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\Cone\Bazar\Models\Order, \Cone\Bazar\Models\Transaction>
order
php
conedevelopment/bazar
src/Models/Transaction.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Transaction.php
MIT
protected function driverName(): Attribute { return new Attribute( get: static function (mixed $value, array $attributes): ?string { try { return Gateway::driver($attributes['driver'])->getName(); } catch (Throwable $exception) { return $attributes['driver']; } } ); }
Get the name of the gateway driver. @return \Illuminate\Database\Eloquent\Casts\Attribute<string|null, never>
driverName
php
conedevelopment/bazar
src/Models/Transaction.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Transaction.php
MIT
protected function url(): Attribute { return new Attribute( get: function (mixed $value, array $attributes): ?string { try { return Gateway::driver($attributes['driver'])->getTransactionUrl($this); } catch (Throwable $exception) { return null; } } ); }
Get the URL of the transaction. @return \Illuminate\Database\Eloquent\Casts\Attribute<string|null, never>
url
php
conedevelopment/bazar
src/Models/Transaction.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Transaction.php
MIT
public function completed(): bool { return ! is_null($this->completed_at); }
Determine if the payment is completed.
completed
php
conedevelopment/bazar
src/Models/Transaction.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Transaction.php
MIT
public function pending(): bool { return ! $this->completed(); }
Determine if the payment is pending.
pending
php
conedevelopment/bazar
src/Models/Transaction.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Transaction.php
MIT
public function scopePayment(Builder $query): Builder { return $query->where($query->qualifyColumn('type'), static::PAYMENT); }
Scope the query to only include payments.
scopePayment
php
conedevelopment/bazar
src/Models/Transaction.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Transaction.php
MIT
public function scopeRefund(Builder $query): Builder { return $query->where($query->qualifyColumn('type'), static::REFUND); }
Scope the query to only include refunds.
scopeRefund
php
conedevelopment/bazar
src/Models/Transaction.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Transaction.php
MIT
public function scopeCompleted(Builder $query): Builder { return $query->whereNotNull($query->qualifyColumn('completed_at')); }
Scope a query to only include completed transactions.
scopeCompleted
php
conedevelopment/bazar
src/Models/Transaction.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Transaction.php
MIT
public function scopePending(Builder $query): Builder { return $query->whereNull($query->qualifyColumn('completed_at')); }
Scope a query to only include pending transactions.
scopePending
php
conedevelopment/bazar
src/Models/Transaction.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Transaction.php
MIT
protected static function newFactory(): VariantFactory { return VariantFactory::new(); }
Create a new factory instance for the model.
newFactory
php
conedevelopment/bazar
src/Models/Variant.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Variant.php
MIT
public function product(): BelongsTo { return $this->belongsTo(Product::getProxiedClass()) ->withDefault(); }
Get the product for the variant.
product
php
conedevelopment/bazar
src/Models/Variant.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Variant.php
MIT
protected function name(): Attribute { return new Attribute( get: fn (): string => sprintf('%s - %s', $this->product->name, $this->alias) ); }
Get the name attribute. @return \Illuminate\Database\Eloquent\Casts\Attribute<string, never>
name
php
conedevelopment/bazar
src/Models/Variant.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Variant.php
MIT
protected function alias(): Attribute { return new Attribute( get: function (?string $value): ?string { return $this->exists ? ($value ?: "#{$this->getKey()}") : $value; } ); }
Get the alias attribute. @return \Illuminate\Database\Eloquent\Casts\Attribute<string|null, never>
alias
php
conedevelopment/bazar
src/Models/Variant.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Variant.php
MIT
public function buyable(Checkoutable $checkoutable): bool { return $this->product->buyable($checkoutable); }
Determine whether the buyable object is available for the checkoutable instance.
buyable
php
conedevelopment/bazar
src/Models/Variant.php
https://github.com/conedevelopment/bazar/blob/master/src/Models/Variant.php
MIT