Skip to content

Commit

Permalink
2.0-beta9 (#161)
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Feb 11, 2022
1 parent c19712e commit 06a74f5
Show file tree
Hide file tree
Showing 75 changed files with 310 additions and 403 deletions.
17 changes: 16 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,30 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

[Unreleased]
## 2.0-beta9 - 2022-02-11

### Fixed

- If an attribute value is null it will be returned instead of the `{"en": null}` encoded string. ([#130](https://github.com/getcandy/getcandy/issues/130))
- When loading an exiting product with channel availabilty, the scheduling modal should no longer display without prompt.
- `Product` and `ProductOption` models will now take the Scout prefix config setting on the indexes.
- The `Text` fieldtype tolerance now accepts numeric values instead of just forcing strings.
- Translating an attribute via `->translateAttribute('name')` will now handle non translatable fields for consistency.
- When using the `getcandy:meilisearch:setup` only indexes available within the app should be affected.
- When installing GetCandy the correct configuration or rich text fields should now be applied. By ([@KKSzymanowski](https://github.com/KKSzymanowski))

### Added

- Added `Taxes` facade to ensure the `TaxManager` can be easily extended. ([#129](https://github.com/getcandy/getcandy/issues/129))
- `collections` relationship has been added to the `Product` model. By ([@poppabear8883](https://github.com/poppabear8883))
- GetCandy's models now support have added macro support. By ([@edcoreweb](https://github.com/edcoreweb))

### Changed

- Instead of assuming `$user->id` we know use `$user->getKey()`. By ([@ryanmitchell](https://github.com/ryanmitchell))
- Big maintainence update to the Docblocks across the codebase to help with IDE support. By ([@KKSzymanowski](https://github.com/KKSzymanowski))

[View Changes](https://github.com/getcandy/core/compare/2.0-beta8...2.0-beta9)

## 2.0-beta8 - 2022-02-01

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class CreateMediaTable extends Migration
{
public function up()
{
if (!Schema::hasTable('media')) {
if (! Schema::hasTable('media')) {
Schema::create('media', function (Blueprint $table) {
$table->bigIncrements('id');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public function up()
{
$tableName = config('activitylog.table_name');

if (!Schema::hasTable($tableName)) {
if (! Schema::hasTable($tableName)) {
Schema::create($tableName, function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('log_name')->nullable();
Expand Down
2 changes: 1 addition & 1 deletion database/state/ConvertProductTypeAttributesToProducts.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public function run()
{
$prefix = config('getcandy.database.table_prefix');

if (!$this->canRun()) {
if (! $this->canRun()) {
return;
}

Expand Down
4 changes: 2 additions & 2 deletions database/state/EnsureDefaultTaxClassExists.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class EnsureDefaultTaxClassExists
{
public function run()
{
if (!$this->canRun() || !$this->shouldRun()) {
if (! $this->canRun() || ! $this->shouldRun()) {
return;
}

Expand All @@ -32,6 +32,6 @@ protected function canRun()

protected function shouldRun()
{
return !TaxClass::whereDefault(true)->count();
return ! TaxClass::whereDefault(true)->count();
}
}
2 changes: 1 addition & 1 deletion database/state/EnsureUserOrdersHaveACustomer.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class EnsureUserOrdersHaveACustomer
{
public function run()
{
if (!$this->canRun()) {
if (! $this->canRun()) {
return;
}

Expand Down
5 changes: 2 additions & 3 deletions src/Actions/Carts/CalculateLine.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ public function __construct(
/**
* Execute the action.
*
* @param \GetCandy\Models\CartLine $cartLine
* @param \Illuminate\Database\Eloquent\Collection $customerGroups
*
* @param \GetCandy\Models\CartLine $cartLine
* @param \Illuminate\Database\Eloquent\Collection $customerGroups
* @return \GetCandy\Models\CartLine
*/
public function execute(
Expand Down
3 changes: 1 addition & 2 deletions src/Actions/Carts/CreateOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ public function __construct(OrderReferenceGeneratorInterface $generator)
/**
* Execute the action.
*
* @param \GetCandy\Models\Cart $cart
*
* @param \GetCandy\Models\Cart $cart
* @return void
*/
public function execute(
Expand Down
5 changes: 2 additions & 3 deletions src/Actions/Carts/MergeCart.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ class MergeCart
/**
* Execute the action.
*
* @param \GetCandy\Models\Cart $target
* @param \GetCandy\Models\Cart $source
*
* @param \GetCandy\Models\Cart $target
* @param \GetCandy\Models\Cart $source
* @return \GetCandy\Models\Cart
*/
public function execute(Cart $target, Cart $source)
Expand Down
9 changes: 4 additions & 5 deletions src/Actions/Carts/ValidateCartForOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ class ValidateCartForOrder
/**
* Execute the action.
*
* @param \GetCandy\Models\Cart $cart
*
* @param \GetCandy\Models\Cart $cart
* @return void
*/
public function execute(
Expand All @@ -32,7 +31,7 @@ public function execute(
}

// Do we have a billing address?
if (!$cart->billingAddress) {
if (! $cart->billingAddress) {
throw new BillingAddressMissingException(
__('getcandy::exceptions.carts.billing_missing')
);
Expand All @@ -49,7 +48,7 @@ public function execute(

// Is this cart shippable and if so, does it have a shipping address.
if ($cart->getManager()->isShippable()) {
if (!$cart->shippingAddress) {
if (! $cart->shippingAddress) {
throw new ShippingAddressMissingException(
__('getcandy::exceptions.carts.shipping_missing')
);
Expand All @@ -65,7 +64,7 @@ public function execute(
}

// Do we have a shipping option applied?
if (!$cart->getManager()->getShippingOption()) {
if (! $cart->getManager()->getShippingOption()) {
throw new ShippingOptionMissingException();
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/Actions/Collections/SortProducts.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ class SortProducts
/**
* Execute the action.
*
* @param \GetCandy\Models\Collection $collection
*
* @param \GetCandy\Models\Collection $collection
* @return void
*/
public function execute(Collection $collection)
Expand Down
7 changes: 3 additions & 4 deletions src/Actions/Collections/SortProductsByPrice.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ class SortProductsByPrice
/**
* Execute the action.
*
* @param \Illuminate\Support\Collection $products
* @param \GetCandy\Models\Currency $currency
* @param string $direction
*
* @param \Illuminate\Support\Collection $products
* @param \GetCandy\Models\Currency $currency
* @param string $direction
* @return void
*/
public function execute(Collection $products, Currency $currency, $direction = 'asc')
Expand Down
5 changes: 2 additions & 3 deletions src/Actions/Collections/SortProductsBySku.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ class SortProductsBySku
/**
* Execute the action.
*
* @param \Illuminate\Support\Collection $products
* @param string $direction
*
* @param \Illuminate\Support\Collection $products
* @param string $direction
* @return \Illuminate\Support\Collection
*/
public function execute(Collection $products, $direction = 'asc')
Expand Down
15 changes: 6 additions & 9 deletions src/Actions/Taxes/GetTaxZonePostcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ class GetTaxZonePostcode
/**
* Execute the action.
*
* @param string $postcode
*
* @param string $postcode
* @return null|\GetCandy\Models\TaxZonePostcode
*/
public function execute($postcode)
Expand All @@ -21,7 +20,7 @@ public function execute($postcode)
return $postcodeZone;
}

if (!$postcodeZone) {
if (! $postcodeZone) {
return null;
}

Expand All @@ -33,7 +32,7 @@ public function execute($postcode)
})->sort(fn ($current, $next) => $current['matches'] < $next['matches'])->first();

// Give up, use default...
if (!$match) {
if (! $match) {
return null;
}

Expand All @@ -43,8 +42,7 @@ public function execute($postcode)
/**
* Return the zone or zones which match this postcode.
*
* @param string $postcode
*
* @param string $postcode
* @return \GetCandy\Models\TaxZonePostcode|\Illuminate\Support\Collection
*/
protected function getZoneMatches($postcode)
Expand All @@ -61,9 +59,8 @@ protected function getZoneMatches($postcode)
/**
* Match wildcard postcodes and return number of matches.
*
* @param string $wildcard
* @param string $haystack
*
* @param string $wildcard
* @param string $haystack
* @return int
*/
private function matchWildcard($wildcard, $haystack)
Expand Down
5 changes: 2 additions & 3 deletions src/Addons/Manifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,12 @@ public function build()
/**
* Format a given composer package into our addon format.
*
* @param array $package
*
* @param array $package
* @return void|array
*/
protected function formatPackage($package)
{
if (!$provider = $package['extra']['laravel']['providers'][0] ?? null) {
if (! $provider = $package['extra']['laravel']['providers'][0] ?? null) {
return;
}

Expand Down
6 changes: 2 additions & 4 deletions src/Base/AttributeManifestInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ interface AttributeManifestInterface
/**
* Add an attribute type.
*
* @param string $classname
*
* @param string $classname
* @return void
*/
public function addType($classname);
Expand All @@ -25,8 +24,7 @@ public function getTypes(): Collection;
/**
* Return an attribute type by it's key.
*
* @param string $handle
*
* @param string $handle
* @return string|null
*/
public function getType($handle);
Expand Down
12 changes: 5 additions & 7 deletions src/Base/BaseModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ abstract class BaseModel extends Model
/**
* Create a new instance of the Model.
*
* @param array $attributes
* @param array $attributes
*/
public function __construct(array $attributes = [])
{
Expand All @@ -26,9 +26,8 @@ public function __construct(array $attributes = [])
/**
* Handle dynamic method calls into the model.
*
* @param string $method
* @param array $parameters
*
* @param string $method
* @param array $parameters
* @return mixed
*/
public function __call($method, $parameters)
Expand All @@ -43,9 +42,8 @@ public function __call($method, $parameters)
/**
* Handle dynamic static method calls into the model.
*
* @param string $method
* @param array $parameters
*
* @param string $method
* @param array $parameters
* @return mixed
*/
public static function __callStatic($method, $parameters)
Expand Down
16 changes: 6 additions & 10 deletions src/Base/CartSessionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,17 @@ public function manager();
/**
* Associate a cart to a user.
*
* @param \GetCandy\Models\Cart $cart
* @param \Illuminate\Contracts\Auth\Authenticatable $user
* @param string $policy
*
* @param \GetCandy\Models\Cart $cart
* @param \Illuminate\Contracts\Auth\Authenticatable $user
* @param string $policy
* @return void
*/
public function associate(Cart $cart, Authenticatable $user, $policy);

/**
* Use the given cart and set to the session.
*
* @param \GetCandy\Models\Cart $cart
*
* @param \GetCandy\Models\Cart $cart
* @return void
*/
public function use(Cart $cart);
Expand All @@ -60,17 +58,15 @@ public function getSessionKey();
/**
* Set the cart session channel.
*
* @param \GetCandy\Models\Channel $channel
*
* @param \GetCandy\Models\Channel $channel
* @return self
*/
public function setChannel(Channel $channel);

/**
* Set the cart session currency.
*
* @param \GetCandy\Models\Currency $currency
*
* @param \GetCandy\Models\Currency $currency
* @return self
*/
public function setCurrency(Currency $currency);
Expand Down
10 changes: 5 additions & 5 deletions src/Base/Casts/AsAttributeData.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ class AsAttributeData implements Castable
/**
* Get the caster class to use when casting from / to this cast target.
*
* @param array $arguments
*
* @param array $arguments
* @return object|string
*/
public static function castUsing(array $arguments)
{
return new class() implements CastsAttributes {
return new class() implements CastsAttributes
{
public function get($model, $key, $value, $attributes)
{
if (!isset($attributes[$key])) {
if (! isset($attributes[$key])) {
return null;
}

Expand All @@ -31,7 +31,7 @@ public function get($model, $key, $value, $attributes)
$returnData = new Collection();

foreach ($data as $key => $item) {
if (!in_array(FieldType::class, class_implements($item['field_type']))) {
if (! in_array(FieldType::class, class_implements($item['field_type']))) {
throw new FieldTypeException('This field type is not supported.');
}
$returnData->put($key, new $item['field_type']($item['value']));
Expand Down
Loading

0 comments on commit 06a74f5

Please sign in to comment.