- Fixing coding style.

- Fixing typo.
This commit is contained in:
Abdullah Al-Faqeir 2021-10-06 15:26:08 +03:00
parent 7b612ecc67
commit 8e3c43bd19
57 changed files with 641 additions and 677 deletions

View File

@ -13,12 +13,12 @@ namespace Database\Factories;
|
*/
class UserFactory extends \Illuminate\Database\Eloquent\Factories\Factory
{
use Illuminate\Database\Eloquent\Factories\Factory;
class UserFactory extends Factory
{
public function definition(): array
{
return [];
}
}

View File

@ -6,15 +6,13 @@ use Illuminate\Http\Resources\Json\JsonResource;
class Attribute extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request
*
* @return array
*/
public function toArray($request)
public function toArray($request): array
{
return [
'id' => $this->id,
@ -27,5 +25,4 @@ class Attribute extends JsonResource
'updated_at' => $this->updated_at,
];
}
}

View File

@ -6,15 +6,13 @@ use Illuminate\Http\Resources\Json\JsonResource;
class AttributeOption extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request
*
* @return array
*/
public function toArray($request)
public function toArray($request): array
{
return [
'id' => $this->id,
@ -23,5 +21,4 @@ class AttributeOption extends JsonResource
'swatch_value' => $this->swatch_value,
];
}
}

View File

@ -40,7 +40,7 @@ class AttributeOption extends TranslatableModel implements AttributeOptionContra
return url('cache/small/' . $this->swatch_value);
}
return;
return null;
}
/**

View File

@ -6,7 +6,6 @@ use Illuminate\Support\ServiceProvider;
class AttributeServiceProvider extends ServiceProvider
{
/**
* Bootstrap services.
*
@ -16,5 +15,4 @@ class AttributeServiceProvider extends ServiceProvider
{
$this->loadMigrationsFrom(__DIR__.'/../Database/Migrations');
}
}

View File

@ -6,7 +6,6 @@ use Illuminate\Support\ServiceProvider;
class BookingProductServiceProvider extends ServiceProvider
{
/**
* Bootstrap services.
*
@ -38,5 +37,4 @@ class BookingProductServiceProvider extends ServiceProvider
{
$this->mergeConfigFrom(dirname(__DIR__) . '/Config/product_types.php', 'product_types');
}
}

View File

@ -14,7 +14,6 @@ use Webkul\Category\Contracts\CategoryTranslation as CategoryTranslationContract
*/
class CategoryTranslation extends Model implements CategoryTranslationContract
{
public $timestamps = false;
protected $fillable = [
@ -26,5 +25,4 @@ class CategoryTranslation extends Model implements CategoryTranslationContract
'meta_keywords',
'locale_id',
];
}

View File

@ -8,12 +8,11 @@ use Webkul\Checkout\Facades\Cart;
class CheckoutServiceProvider extends ServiceProvider
{
public function boot(): void
{
include __DIR__.'/../Http/helpers.php';
include __DIR__ . '/../Http/helpers.php';
$this->loadMigrationsFrom(__DIR__.'/../Database/Migrations');
$this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations');
$this->app->register(ModuleServiceProvider::class);
@ -49,5 +48,4 @@ class CheckoutServiceProvider extends ServiceProvider
$this->app->bind('cart', 'Webkul\Checkout\Cart');
}
}

View File

@ -145,7 +145,7 @@ class Core
}
/**
* Returns currenct channel models.
* Returns current channel models.
*
* @return \Webkul\Core\Contracts\Channel
*/

View File

@ -32,7 +32,6 @@ use Webkul\Product\Models\ProductDownloadableLinkTranslation;
*/
class Laravel5Helper extends Laravel
{
public const SIMPLE_PRODUCT = 1;
public const VIRTUAL_PRODUCT = 2;
@ -92,7 +91,7 @@ class Laravel5Helper extends Laravel
$grand_total = '0.0000';
$base_grand_total = '0.0000';
} else {
$grand_total = (string) $faker->numberBetween(1, 666);
$grand_total = (string)$faker->numberBetween(1, 666);
$base_grand_total = $grand_total;
}
@ -451,5 +450,4 @@ class Laravel5Helper extends Laravel
return $data;
}
}

View File

@ -1,9 +1,7 @@
<?php
namespace Webkul\Core\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
@ -12,7 +10,6 @@ use Webkul\Core\Contracts\Address as AddressContract;
/**
* Class Address
*
* @package Webkul\Core\Models
*
* @property string $address_type
@ -41,7 +38,6 @@ use Webkul\Core\Contracts\Address as AddressContract;
*/
abstract class Address extends Model implements AddressContract
{
protected $table = 'addresses';
protected $guarded = [
@ -82,7 +78,7 @@ abstract class Address extends Model implements AddressContract
*/
public function getNameAttribute(): string
{
return $this->first_name.' '.$this->last_name;
return $this->first_name . ' ' . $this->last_name;
}
/**
@ -92,5 +88,4 @@ abstract class Address extends Model implements AddressContract
{
return $this->belongsTo(Customer::class);
}
}

View File

@ -6,7 +6,7 @@ use Konekt\Concord\BaseModuleServiceProvider;
class CoreModuleServiceProvider extends BaseModuleServiceProvider
{
public function boot()
public function boot(): void
{
if ($this->areMigrationsEnabled()) {
$this->registerMigrations();

View File

@ -17,7 +17,6 @@ use Webkul\Theme\ViewRenderEventManager;
class CoreServiceProvider extends ServiceProvider
{
/**
* Bootstrap services.
*
@ -25,11 +24,11 @@ class CoreServiceProvider extends ServiceProvider
*/
public function boot(): void
{
include __DIR__.'/../Http/helpers.php';
include __DIR__ . '/../Http/helpers.php';
$this->loadMigrationsFrom(__DIR__.'/../Database/Migrations');
$this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations');
$this->loadTranslationsFrom(__DIR__.'/../Resources/lang', 'core');
$this->loadTranslationsFrom(__DIR__ . '/../Resources/lang', 'core');
Validator::extend('slug', 'Webkul\Core\Contracts\Validations\Slug@passes');
@ -38,15 +37,15 @@ class CoreServiceProvider extends ServiceProvider
Validator::extend('decimal', 'Webkul\Core\Contracts\Validations\Decimal@passes');
$this->publishes([
dirname(__DIR__).'/Config/concord.php' => config_path('concord.php'),
dirname(__DIR__).'/Config/scout.php' => config_path('scout.php'),
dirname(__DIR__) . '/Config/concord.php' => config_path('concord.php'),
dirname(__DIR__) . '/Config/scout.php' => config_path('scout.php'),
]);
$this->app->bind(ExceptionHandler::class, Handler::class);
SliderProxy::observe(SliderObserver::class);
$this->loadViewsFrom(__DIR__.'/../Resources/views', 'core');
$this->loadViewsFrom(__DIR__ . '/../Resources/views', 'core');
Event::listen('bagisto.shop.layout.body.after', static function (ViewRenderEventManager $viewRenderEventManager) {
$viewRenderEventManager->addTemplate('core::blade.tracer.style');
@ -127,5 +126,4 @@ class CoreServiceProvider extends ServiceProvider
return new BladeCompiler($app['files'], $app['config']['view.compiled']);
});
}
}

View File

@ -3,6 +3,7 @@
namespace Webkul\Customer\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Webkul\Customer\Database\Factories\CustomerGroupFactory;
use Webkul\Customer\Contracts\CustomerGroup as CustomerGroupContract;
@ -22,7 +23,7 @@ class CustomerGroup extends Model implements CustomerGroupContract
/**
* Get the customers for this group.
*/
public function customers(): \Illuminate\Database\Eloquent\Relations\HasMany
public function customers(): HasMany
{
return $this->hasMany(CustomerProxy::modelClass());
}

View File

@ -10,21 +10,21 @@ use Webkul\Customer\Http\Middleware\RedirectIfNotCustomer;
class CustomerServiceProvider extends ServiceProvider
{
/**
* Bootstrap application services.
*
* @param \Illuminate\Routing\Router $router
* @return void
*/
public function boot(Router $router)
public function boot(Router $router): void
{
$router->aliasMiddleware('customer', RedirectIfNotCustomer::class);
$this->loadMigrationsFrom(__DIR__.'/../Database/Migrations');
$this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations');
$this->loadTranslationsFrom(__DIR__.'/../Resources/lang', 'customer');
$this->loadTranslationsFrom(__DIR__ . '/../Resources/lang', 'customer');
$this->loadViewsFrom(__DIR__.'/../Resources/views', 'customer');
$this->loadViewsFrom(__DIR__ . '/../Resources/views', 'customer');
$this->app['validator']->extend('captcha', function ($attribute, $value, $parameters) {
return $this->app['captcha']->validateResponse($value);
@ -52,7 +52,6 @@ class CustomerServiceProvider extends ServiceProvider
*/
protected function registerConfig(): void
{
$this->mergeConfigFrom(dirname(__DIR__).'/Config/system.php', 'core');
$this->mergeConfigFrom(dirname(__DIR__) . '/Config/system.php', 'core');
}
}

View File

@ -6,7 +6,6 @@ use Illuminate\Support\ServiceProvider;
class InventoryServiceProvider extends ServiceProvider
{
/**
* Bootstrap services.
*
@ -14,7 +13,7 @@ class InventoryServiceProvider extends ServiceProvider
*/
public function boot(): void
{
$this->loadMigrationsFrom(__DIR__.'/../Database/Migrations');
$this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations');
}
/**
@ -25,5 +24,4 @@ class InventoryServiceProvider extends ServiceProvider
public function register(): void
{
}
}

View File

@ -1,13 +1,13 @@
<?php
namespace Webkul\Category\Database\Seeders;
namespace Webkul\Product\Database\Seeders;
use Illuminate\Support\Facades\DB;
use Illuminate\Database\Seeder;
class ProductTableSeeder extends Seeder
{
public function run()
public function run(): void
{
//dd('running');
}

View File

@ -15,7 +15,6 @@ use Webkul\Product\ProductVideo;
class ProductServiceProvider extends ServiceProvider
{
/**
* Bootstrap services.
*
@ -23,14 +22,14 @@ class ProductServiceProvider extends ServiceProvider
*/
public function boot(): void
{
include __DIR__.'/../Http/helpers.php';
include __DIR__ . '/../Http/helpers.php';
$this->loadMigrationsFrom(__DIR__.'/../Database/Migrations');
$this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations');
$this->app->register(EventServiceProvider::class);
$this->publishes([
dirname(__DIR__).'/Config/imagecache.php' => config_path('imagecache.php'),
dirname(__DIR__) . '/Config/imagecache.php' => config_path('imagecache.php'),
]);
ProductProxy::observe(ProductObserver::class);
@ -57,7 +56,7 @@ class ProductServiceProvider extends ServiceProvider
*/
public function registerConfig(): void
{
$this->mergeConfigFrom(dirname(__DIR__).'/Config/product_types.php', 'product_types');
$this->mergeConfigFrom(dirname(__DIR__) . '/Config/product_types.php', 'product_types');
}
/**
@ -97,5 +96,4 @@ class ProductServiceProvider extends ServiceProvider
return app()->make(ProductVideo::class);
});
}
}

View File

@ -6,6 +6,10 @@ use Webkul\Checkout\Models\CartProxy;
use Illuminate\Database\Eloquent\Model;
use Webkul\Sales\Contracts\Order as OrderContract;
use Webkul\Sales\Database\Factories\OrderFactory;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\MorphTo;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class Order extends Model implements OrderContract
@ -83,7 +87,7 @@ class Order extends Model implements OrderContract
/**
* Get the associated cart that was used to create this order.
*/
public function cart(): \Illuminate\Database\Eloquent\Relations\BelongsTo
public function cart(): BelongsTo
{
return $this->belongsTo(CartProxy::modelClass());
}
@ -91,7 +95,7 @@ class Order extends Model implements OrderContract
/**
* Get the order items record associated with the order.
*/
public function items(): \Illuminate\Database\Eloquent\Relations\HasMany
public function items(): HasMany
{
return $this->hasMany(OrderItemProxy::modelClass())
->whereNull('parent_id');
@ -100,7 +104,7 @@ class Order extends Model implements OrderContract
/**
* Get the comments record associated with the order.
*/
public function comments(): \Illuminate\Database\Eloquent\Relations\HasMany
public function comments(): HasMany
{
return $this->hasMany(OrderCommentProxy::modelClass());
}
@ -108,7 +112,7 @@ class Order extends Model implements OrderContract
/**
* Get the order items record associated with the order.
*/
public function all_items(): \Illuminate\Database\Eloquent\Relations\HasMany
public function all_items(): HasMany
{
return $this->hasMany(OrderItemProxy::modelClass());
}
@ -116,7 +120,7 @@ class Order extends Model implements OrderContract
/**
* Get the order shipments record associated with the order.
*/
public function shipments(): \Illuminate\Database\Eloquent\Relations\HasMany
public function shipments(): HasMany
{
return $this->hasMany(ShipmentProxy::modelClass());
}
@ -124,7 +128,7 @@ class Order extends Model implements OrderContract
/**
* Get the order invoices record associated with the order.
*/
public function invoices(): \Illuminate\Database\Eloquent\Relations\HasMany
public function invoices(): HasMany
{
return $this->hasMany(InvoiceProxy::modelClass());
}
@ -132,7 +136,7 @@ class Order extends Model implements OrderContract
/**
* Get the order refunds record associated with the order.
*/
public function refunds(): \Illuminate\Database\Eloquent\Relations\HasMany
public function refunds(): HasMany
{
return $this->hasMany(RefundProxy::modelClass());
}
@ -140,7 +144,7 @@ class Order extends Model implements OrderContract
/**
* Get the order transactions record associated with the order.
*/
public function transactions(): \Illuminate\Database\Eloquent\Relations\HasMany
public function transactions(): HasMany
{
return $this->hasMany(OrderTransactionProxy::modelClass());
}
@ -148,7 +152,7 @@ class Order extends Model implements OrderContract
/**
* Get the customer record associated with the order.
*/
public function customer(): \Illuminate\Database\Eloquent\Relations\MorphTo
public function customer(): MorphTo
{
return $this->morphTo();
}
@ -156,7 +160,7 @@ class Order extends Model implements OrderContract
/**
* Get the addresses for the order.
*/
public function addresses(): \Illuminate\Database\Eloquent\Relations\HasMany
public function addresses(): HasMany
{
return $this->hasMany(OrderAddressProxy::modelClass());
}
@ -164,7 +168,7 @@ class Order extends Model implements OrderContract
/**
* Get the payment for the order.
*/
public function payment(): \Illuminate\Database\Eloquent\Relations\HasOne
public function payment(): HasOne
{
return $this->hasOne(OrderPaymentProxy::modelClass());
}
@ -172,7 +176,7 @@ class Order extends Model implements OrderContract
/**
* Get the billing address for the order.
*/
public function billing_address(): \Illuminate\Database\Eloquent\Relations\HasMany
public function billing_address(): HasMany
{
return $this->addresses()
->where('address_type', OrderAddress::ADDRESS_TYPE_BILLING);
@ -190,7 +194,7 @@ class Order extends Model implements OrderContract
/**
* Get the shipping address for the order.
*/
public function shipping_address(): \Illuminate\Database\Eloquent\Relations\HasMany
public function shipping_address(): HasMany
{
return $this->addresses()
->where('address_type', OrderAddress::ADDRESS_TYPE_SHIPPING);

View File

@ -41,7 +41,7 @@ class OrderItem extends Model implements OrderItemContract
return $this->typeInstance;
}
$this->typeInstance = app(config('product_types.'.$this->type.'.class'));
$this->typeInstance = app(config('product_types.' . $this->type . '.class'));
if ($this->product) {
$this->typeInstance->setProduct($this);

View File

@ -6,10 +6,9 @@ use Illuminate\Support\ServiceProvider;
class SalesServiceProvider extends ServiceProvider
{
public function boot(): void
{
$this->loadMigrationsFrom(__DIR__.'/../Database/Migrations');
$this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations');
}
/**
@ -19,7 +18,6 @@ class SalesServiceProvider extends ServiceProvider
*/
public function register(): void
{
$this->mergeConfigFrom(dirname(__DIR__).'/Config/system.php', 'core');
$this->mergeConfigFrom(dirname(__DIR__) . '/Config/system.php', 'core');
}
}

View File

@ -25,7 +25,6 @@ use Cart;
class cartRuleWithCoupon
{
public $cartRule;
public $coupon;
@ -35,12 +34,10 @@ class cartRuleWithCoupon
$this->cartRule = $cartRule;
$this->coupon = $coupon;
}
}
class expectedCartItem implements Arrayable
{
public const ITEM_DISCOUNT_AMOUNT_PRECISION = 4;
public const ITEM_TAX_AMOUNT_PRECISION = 4;
@ -98,7 +95,7 @@ class expectedCartItem implements Arrayable
$this->discount_amount = $this->quantity * $discount;
$this->base_discount_amount = $this->quantity * $baseDiscount;
$this->coupon_code = $code;
$this->applied_cart_rule_ids = (string) $cartRuleId;
$this->applied_cart_rule_ids = (string)$cartRuleId;
}
public function calcPercentageDiscountAmounts(float $discount, string $code, int $cartRuleId): void
@ -107,7 +104,7 @@ class expectedCartItem implements Arrayable
$this->discount_amount = round(($this->total + $this->tax_amount) * $this->discount_percent / 100, self::ITEM_DISCOUNT_AMOUNT_PRECISION);
$this->base_discount_amount = round(($this->base_total + $this->base_tax_amount) * $this->discount_percent / 100, self::ITEM_DISCOUNT_AMOUNT_PRECISION);
$this->coupon_code = $code;
$this->applied_cart_rule_ids = (string) $cartRuleId;
$this->applied_cart_rule_ids = (string)$cartRuleId;
}
public function toArray(): array
@ -130,12 +127,10 @@ class expectedCartItem implements Arrayable
'applied_cart_rule_ids' => $this->applied_cart_rule_ids,
];
}
}
class expectedCart
{
public const CART_TOTAL_PRECISION = 2;
public $customer_id;
@ -175,7 +170,7 @@ class expectedCart
public function applyCoupon(int $cartRuleId, string $couponCode): void
{
$this->coupon_code = $couponCode;
$this->applied_cart_rule_ids = (string) $cartRuleId;
$this->applied_cart_rule_ids = (string)$cartRuleId;
}
public function finalizeTotals(): void
@ -193,14 +188,12 @@ class expectedCart
public function toArray(): array
{
return (array) $this;
return (array)$this;
}
}
class expectedOrder implements Arrayable
{
public $status;
public $customer_email;
@ -298,12 +291,10 @@ class expectedOrder implements Arrayable
'shipping_discount_amount' => $this->shipping_discount_amount,
];
}
}
class CartRuleCest
{
private $products;
private $sessionToken;
@ -624,7 +615,7 @@ class CartRuleCest
if ($scenario['withCoupon']) {
$expectedCartCoupon = $cartRuleWithCoupon->coupon->code;
$I->comment('I try to use coupon code '.$expectedCartCoupon);
$I->comment('I try to use coupon code ' . $expectedCartCoupon);
cart()
->setCouponCode($expectedCartCoupon)
->collectTotals();
@ -940,14 +931,14 @@ class CartRuleCest
$baseDiscountAmount -= $cartItems[$i]->discount_amount;
$cartItems[$i]->coupon_code = $cartRuleWithCoupon->coupon->code;
$cartItems[$i]->applied_cart_rule_ids = (string) $cartRuleWithCoupon->cartRule->id;
$cartItems[$i]->applied_cart_rule_ids = (string)$cartRuleWithCoupon->cartRule->id;
}
$cartItems[$length]->discount_amount = $discountAmount;
$cartItems[$length]->base_discount_amount = $baseDiscountAmount;
$cartItems[$length]->coupon_code = $cartRuleWithCoupon->coupon->code;
$cartItems[$length]->applied_cart_rule_ids = (string) $cartRuleWithCoupon->cartRule->id;
$cartItems[$length]->applied_cart_rule_ids = (string)$cartRuleWithCoupon->cartRule->id;
return $cartItems;
}
@ -1251,6 +1242,4 @@ class CartRuleCest
return null;
}
}