Improved code style

This commit is contained in:
Jitendra Singh 2020-02-27 13:33:03 +05:30
parent 0f42e8ff8f
commit 05be7a070a
146 changed files with 1211 additions and 880 deletions

View File

@ -59,8 +59,7 @@ class AddressDataGrid extends DataGrid
->on('countries.id', 'country_states.country_id');
});
$queryBuilder
->groupBy('ca.id')
$queryBuilder->groupBy('ca.id')
->addSelect(DB::raw(DB::getTablePrefix() . 'country_states.default_name as state_name'));
$this->addFilter('address_id', 'ca.id');

View File

@ -9,7 +9,23 @@ class Attribute extends TranslatableModel implements AttributeContract
{
public $translatedAttributes = ['name'];
protected $fillable = ['code', 'admin_name', 'type', 'position', 'is_required', 'is_unique', 'validation', 'value_per_locale', 'value_per_channel', 'is_filterable', 'is_configurable', 'is_visible_on_front', 'is_user_defined', 'swatch_type', 'use_in_flat'];
protected $fillable = [
'code',
'admin_name',
'type',
'position',
'is_required',
'is_unique',
'validation',
'value_per_locale',
'value_per_channel',
'is_filterable',
'is_configurable',
'is_visible_on_front',
'is_user_defined',
'swatch_type',
'use_in_flat',
];
// protected $with = ['options'];

View File

@ -27,8 +27,9 @@ class AttributeOption extends TranslatableModel implements AttributeOptionContra
*/
public function swatch_value_url()
{
if ($this->swatch_value && $this->attribute->swatch_type == 'image')
if ($this->swatch_value && $this->attribute->swatch_type == 'image') {
return Storage::url($this->swatch_value);
}
return;
}

View File

@ -412,7 +412,8 @@ class Booking
'attribute_name' => 'Rent Till',
'option_id' => 0,
'option_label' => Carbon::createFromTimeString($bookingProduct->available_to)->format('d F, Y'),
]];
]
];
break;
@ -442,7 +443,8 @@ class Booking
'attribute_name' => 'Rent Till',
'option_id' => 0,
'option_label' => $to,
]];
]
];
break;
@ -458,7 +460,8 @@ class Booking
'attribute_name' => 'Booking Till',
'option_id' => 0,
'option_label' => Carbon::createFromTimestamp($timestamps[1])->format('d F, Y h:i A'),
]];
]
];
break;
}

View File

@ -11,7 +11,15 @@ class Booking extends Model implements BookingContract
{
public $timestamps = false;
protected $fillable = ['qty', 'from', 'to', 'order_item_id', 'booking_product_event_ticket_id', 'product_id', 'order_id'];
protected $fillable = [
'qty',
'from',
'to',
'order_item_id',
'booking_product_event_ticket_id',
'product_id',
'order_id',
];
/**
* Get the order record associated with the order item.

View File

@ -8,7 +8,16 @@ use Webkul\BookingProduct\Contracts\BookingProduct as BookingProductContract;
class BookingProduct extends Model implements BookingProductContract
{
protected $fillable = ['location', 'show_location', 'type', 'qty', 'available_every_week', 'available_from', 'available_to', 'product_id'];
protected $fillable = [
'location',
'show_location',
'type',
'qty',
'available_every_week',
'available_from',
'available_to',
'product_id',
];
protected $with = ['default_slot', 'appointment_slot', 'event_tickets', 'rental_slot', 'table_slot'];

View File

@ -11,5 +11,15 @@ class BookingProductTableSlot extends Model implements BookingProductTableSlotCo
protected $casts = ['slots' => 'array'];
protected $fillable = ['price_type', 'guest_limit', 'guest_capacity', 'duration', 'break_time', 'prevent_scheduling_before', 'same_slot_all_days', 'slots', 'booking_product_id'];
protected $fillable = [
'price_type',
'guest_limit',
'guest_capacity',
'duration',
'break_time',
'prevent_scheduling_before',
'same_slot_all_days',
'slots',
'booking_product_id',
];
}

View File

@ -10,7 +10,15 @@ class CmsPage extends TranslatableModel implements CmsPageContract
{
protected $fillable = ['layout'];
public $translatedAttributes = ['content', 'meta_description', 'meta_title', 'page_title', 'meta_keywords', 'html_content', 'url_key'];
public $translatedAttributes = [
'content',
'meta_description',
'meta_title',
'page_title',
'meta_keywords',
'html_content',
'url_key',
];
protected $with = ['translations'];

View File

@ -9,5 +9,14 @@ class CmsPageTranslation extends Model implements CmsPageTranslationContract
{
public $timestamps = false;
protected $fillable = ['page_title', 'url_key', 'html_content', 'meta_title', 'meta_description', 'meta_keywords', 'locale', 'cms_page_id'];
protected $fillable = [
'page_title',
'url_key',
'html_content',
'meta_title',
'meta_description',
'meta_keywords',
'locale',
'cms_page_id',
];
}

View File

@ -7,7 +7,16 @@ use Webkul\CartRule\Contracts\CartRuleCoupon as CartRuleCouponContract;
class CartRuleCoupon extends Model implements CartRuleCouponContract
{
protected $fillable = ['code', 'usage_limit', 'usage_per_customer', 'times_used', 'type', 'cart_rule_id', 'expired_at', 'is_primary'];
protected $fillable = [
'code',
'usage_limit',
'usage_per_customer',
'times_used',
'type',
'cart_rule_id',
'expired_at',
'is_primary',
];
/**
* Get the cart rule that owns the cart rule coupon.

View File

@ -126,10 +126,12 @@ class CatalogRuleIndex
$catalogRules = $this->catalogRuleRepository->scopeQuery(function($query) {
return $query->where(function ($query1) {
$query1->where('catalog_rules.starts_from', '<=', Carbon::now()->format('Y-m-d'))->orWhereNull('catalog_rules.starts_from');
$query1->where('catalog_rules.starts_from', '<=', Carbon::now()->format('Y-m-d'))
->orWhereNull('catalog_rules.starts_from');
})
->where(function ($query2) {
$query2->where('catalog_rules.ends_till', '>=', Carbon::now()->format('Y-m-d'))->orWhereNull('catalog_rules.ends_till');
$query2->where('catalog_rules.ends_till', '>=', Carbon::now()->format('Y-m-d'))
->orWhereNull('catalog_rules.ends_till');
})
->orderBy('sort_order', 'asc');
})->findWhere(['status' => 1]);

View File

@ -9,7 +9,19 @@ use Webkul\Customer\Models\CustomerGroupProxy;
class CatalogRule extends Model implements CatalogRuleContract
{
protected $fillable = ['name', 'description', 'starts_from', 'ends_till', 'status', 'condition_type', 'conditions', 'end_other_rules', 'action_type', 'discount_amount', 'sort_order'];
protected $fillable = [
'name',
'description',
'starts_from',
'ends_till',
'status',
'condition_type',
'conditions',
'end_other_rules',
'action_type',
'discount_amount',
'sort_order',
];
protected $casts = [
'conditions' => 'array'

View File

@ -9,5 +9,16 @@ class CatalogRuleProduct extends Model implements CatalogRuleProductContract
{
public $timestamps = false;
protected $fillable = ['starts_from', 'ends_till', 'discount_amount', 'action_type', 'end_other_rules', 'sort_order', 'catalog_rule_id', 'channel_id', 'customer_group_id', 'product_id'];
protected $fillable = [
'starts_from',
'ends_till',
'discount_amount',
'action_type',
'end_other_rules',
'sort_order',
'catalog_rule_id',
'channel_id',
'customer_group_id',
'product_id',
];
}

View File

@ -9,5 +9,13 @@ class CatalogRuleProductPrice extends Model implements CatalogRuleProductPriceCo
{
public $timestamps = false;
protected $fillable = ['price', 'rule_date', 'starts_from', 'ends_till', 'catalog_rule_id', 'channel_id', 'customer_group_id'];
protected $fillable = [
'price',
'rule_date',
'starts_from',
'ends_till',
'catalog_rule_id',
'channel_id',
'customer_group_id',
];
}

View File

@ -15,11 +15,31 @@ class CategoryTableSeeder extends Seeder
$now = Carbon::now();
DB::table('categories')->insert([
['id' => '1','position' => '1','image' => NULL,'status' => '1','_lft' => '1','_rgt' => '14','parent_id' => NULL, 'created_at' => $now, 'updated_at' => $now]
[
'id' => '1',
'position' => '1',
'image' => NULL,
'status' => '1',
'_lft' => '1',
'_rgt' => '14',
'parent_id' => NULL,
'created_at' => $now,
'updated_at' => $now,
]
]);
DB::table('category_translations')->insert([
['id' => '1','name' => 'Root','slug' => 'root','description' => 'Root','meta_title' => '','meta_description' => '','meta_keywords' => '','category_id' => '1','locale' => 'en']
[
'id' => '1',
'name' => 'Root',
'slug' => 'root',
'description' => 'Root',
'meta_title' => '',
'meta_description' => '',
'meta_keywords' => '',
'category_id' => '1',
'locale' => 'en',
]
]);
}
}

View File

@ -21,7 +21,15 @@ class Category extends TranslatableModel implements CategoryContract
{
use NodeTrait;
public $translatedAttributes = ['name', 'description', 'slug', 'url_path', 'meta_title', 'meta_description', 'meta_keywords'];
public $translatedAttributes = [
'name',
'description',
'slug',
'url_path',
'meta_title',
'meta_description',
'meta_keywords',
];
protected $fillable = ['position', 'status', 'display_mode', 'parent_id'];

View File

@ -556,11 +556,13 @@ class Cart
}
} else {
if (isset($billingAddress['use_for_shipping']) && $billingAddress['use_for_shipping']) {
$this->cartAddressRepository->create(array_merge($billingAddress,
['address_type' => 'shipping']));
$this->cartAddressRepository->create(
array_merge($billingAddress, ['address_type' => 'shipping'])
);
} else {
$this->cartAddressRepository->create(array_merge($shippingAddress,
['address_type' => 'shipping']));
$this->cartAddressRepository->create(
array_merge($shippingAddress, ['address_type' => 'shipping'])
);
}
}
}
@ -569,9 +571,13 @@ class Cart
if ($cart->haveStockableItems()) {
if (isset($billingAddress['use_for_shipping']) && $billingAddress['use_for_shipping']) {
$this->cartAddressRepository->create(array_merge($billingAddress, ['address_type' => 'shipping']));
$this->cartAddressRepository->create(
array_merge($billingAddress, ['address_type' => 'shipping'])
);
} else {
$this->cartAddressRepository->create(array_merge($shippingAddress, ['address_type' => 'shipping']));
$this->cartAddressRepository->create(
array_merge($shippingAddress, ['address_type' => 'shipping'])
);
}
}
}

View File

@ -7,6 +7,7 @@ use Webkul\Checkout\Models\CartAddress;
$factory->define(CartAddress::class, function (Faker $faker) {
$now = date("Y-m-d H:i:s");
return [
'first_name' => $faker->firstName(),
'last_name' => $faker->lastName,

View File

@ -7,7 +7,17 @@ use Webkul\Checkout\Contracts\CartShippingRate as CartShippingRateContract;
class CartShippingRate extends Model implements CartShippingRateContract
{
protected $fillable = ['carrier', 'carrier_title', 'method', 'method_title', 'method_description', 'price', 'base_price', 'discount_amount', 'base_discount_amount'];
protected $fillable = [
'carrier',
'carrier_title',
'method',
'method_title',
'method_description',
'price',
'base_price',
'discount_amount',
'base_discount_amount',
];
/**
* Get the post that owns the comment.

View File

@ -966,6 +966,7 @@ class Core
}
$finalKey = array_shift($keys);
if (isset($array[$finalKey])) {
$array[$finalKey] = $this->arrayMerge($array[$finalKey], $value);
} else {
@ -978,6 +979,7 @@ class Core
protected function arrayMerge(array &$array1, array &$array2)
{
$merged = $array1;
foreach ($array2 as $key => &$value) {
if (is_array($value) && isset($merged[$key]) && is_array($merged[$key])) {
$merged[$key] = $this->arrayMerge($merged[$key], $value);

View File

@ -22,6 +22,7 @@ class CurrencyTableSeeder extends Seeder
'code' => 'EUR',
'name' => 'Euro',
'symbol' => '€'
]);
]
);
}
}

View File

@ -21,6 +21,7 @@ class LocalesTableSeeder extends Seeder
'id' => 2,
'code' => 'fr',
'name' => 'French',
]);
]
);
}
}

View File

@ -24,6 +24,7 @@ class TranslatableModel extends Model
protected function isKeyALocale($key)
{
$chunks = explode('-', $key);
if (count($chunks) > 1) {
if (Locale::where('code', '=', end($chunks))->first()) {
return true;
@ -47,8 +48,7 @@ class TranslatableModel extends Model
return $this->defaultLocale;
}
return config('translatable.locale')
?: app()->make('translator')->getLocale();
return config('translatable.locale') ?: app()->make('translator')->getLocale();
}
}

View File

@ -58,6 +58,7 @@ class Laravel5Helper extends Laravel5
'brand' => 'text_value',
'guest_checkout' => 'boolean_value',
];
if (! array_key_exists($attribute, $attributes)) {
return null;
}
@ -222,6 +223,7 @@ class Laravel5Helper extends Laravel5
private function createAttributeValues(int $productId, array $attributeValues = []): void
{
$I = $this;
$productAttributeValues = [
'sku',
'url_key',

View File

@ -87,7 +87,7 @@ class ExchangeRateController extends Controller
{
$this->validate(request(), [
'target_currency' => ['required', 'unique:currency_exchange_rates,target_currency'],
'rate' => 'required|numeric'
'rate' => 'required|numeric',
]);
Event::dispatch('core.exchange_rate.create.before');
@ -126,7 +126,7 @@ class ExchangeRateController extends Controller
{
$this->validate(request(), [
'target_currency' => ['required', 'unique:currency_exchange_rates,target_currency,' . $id],
'rate' => 'required|numeric'
'rate' => 'required|numeric',
]);
Event::dispatch('core.exchange_rate.update.before', $id);
@ -155,8 +155,8 @@ class ExchangeRateController extends Controller
'success' => false,
'rates' => null,
'error' => trans('admin::app.exchange-rate.exchange-class-not-found', [
'service' => $service
])
'service' => $service,
]),
], 400);
}
@ -165,13 +165,13 @@ class ExchangeRateController extends Controller
return response()->json([
'success' => true,
'rates' => 'rates'
'rates' => 'rates',
], 200);
} else {
return response()->json([
'success' => false,
'rates' => null,
'error' => trans('admin::app.exchange-rate.invalid-config')
'error' => trans('admin::app.exchange-rate.invalid-config'),
], 400);
}
}

View File

@ -70,7 +70,7 @@ class LocaleController extends Controller
$this->validate(request(), [
'code' => ['required', 'unique:locales,code', new \Webkul\Core\Contracts\Validations\Code],
'name' => 'required',
'direction' => 'in:ltr,rtl'
'direction' => 'in:ltr,rtl',
]);
Event::dispatch('core.locale.create.before');
@ -108,7 +108,7 @@ class LocaleController extends Controller
$this->validate(request(), [
'code' => ['required', 'unique:locales,code,' . $id, new \Webkul\Core\Contracts\Validations\Code],
'name' => 'required',
'direction' => 'in:ltr,rtl'
'direction' => 'in:ltr,rtl',
]);
Event::dispatch('core.locale.update.before', $id);

View File

@ -76,7 +76,7 @@ class SliderController extends Controller
$this->validate(request(), [
'title' => 'string|required',
'channel_id' => 'required',
'image.*' => 'required|mimes:jpeg,bmp,png,jpg'
'image.*' => 'required|mimes:jpeg,bmp,png,jpg',
]);
$result = $this->sliderRepository->save(request()->all());
@ -111,11 +111,12 @@ class SliderController extends Controller
$this->validate(request(), [
'title' => 'string|required',
'channel_id' => 'required',
'image.*' => 'sometimes|mimes:jpeg,bmp,png,jpg'
'image.*' => 'sometimes|mimes:jpeg,bmp,png,jpg',
]);
if ( is_null(request()->image)) {
session()->flash('error', trans('admin::app.settings.sliders.update-fail'));
return redirect()->back();
}

View File

@ -78,10 +78,11 @@ class SubscriptionController extends Controller
$result = $subscriber->update($data);
if ($result)
if ($result) {
session()->flash('success', trans('admin::app.customers.subscribers.update-success'));
else
} else {
session()->flash('error', trans('admin::app.customers.subscribers.update-failed'));
}
return redirect()->route($this->_config['redirect']);
}
@ -104,6 +105,7 @@ class SubscriptionController extends Controller
return response()->json(['message' => true], 200);
} catch (\Exception $e) {
report($e);
session()->flash('error', trans('admin::app.response.delete-failed', ['name' => 'Subscriber']));
}

View File

@ -10,7 +10,19 @@ use Webkul\Core\Contracts\Channel as ChannelContract;
class Channel extends Model implements ChannelContract
{
protected $fillable = ['code', 'name', 'description', 'theme', 'home_page_content', 'footer_content', 'hostname', 'default_locale_id', 'base_currency_id', 'root_category_id', 'home_seo'];
protected $fillable = [
'code',
'name',
'description',
'theme',
'home_page_content',
'footer_content',
'hostname',
'default_locale_id',
'base_currency_id',
'root_category_id',
'home_seo',
];
/**
* Get the channel locales.

View File

@ -16,7 +16,10 @@ class CoreConfig extends Model implements CoreConfigContract
protected $table = 'core_config';
protected $fillable = [
'code', 'value','channel_code','locale_code'
'code',
'value',
'channel_code',
'locale_code',
];
protected $hidden = ['token'];

View File

@ -13,6 +13,7 @@ class CurrencyExchangeRate extends Model implements CurrencyExchangeRateContract
* @var array
*/
protected $fillable = [
'target_currency', 'rate'
'target_currency',
'rate',
];
}

View File

@ -13,6 +13,8 @@ class Locale extends Model implements LocaleContract
* @var array
*/
protected $fillable = [
'code', 'name', 'direction'
'code',
'name',
'direction',
];
}

View File

@ -16,7 +16,10 @@ class Slider extends Model implements SliderContract
protected $table = 'sliders';
protected $fillable = [
'title', 'path', 'content', 'channel_id'
'title',
'path',
'content',
'channel_id',
];
/**

View File

@ -16,7 +16,10 @@ class SubscribersList extends Model implements SubscribersListContract
protected $table = 'subscribers_list';
protected $fillable = [
'email', 'is_subscribed', 'token', 'channel_id'
'email',
'is_subscribed',
'token',
'channel_id',
];
protected $hidden = ['token'];

View File

@ -117,6 +117,7 @@ class CoreConfigRepository extends Repository
*/
public function recuressiveArray(array $formData, $method) {
static $data = [];
static $recuressiveArrayData = [];
foreach ($formData as $form => $formValue) {

View File

@ -31,7 +31,6 @@ class CurrencyRepository extends Repository
} else {
return false;
}
}
}
}

View File

@ -190,6 +190,7 @@ class RegistrationController extends Controller
return redirect()->back();
}
session()->flash('success', trans('shop::app.customer.signup-form.verification-sent'));
return redirect()->back();

View File

@ -24,6 +24,7 @@ class RedirectIfNotCustomer
Auth::guard($guard)->logout();
session()->flash('warning', trans('shop::app.customer.login-form.not-activated'));
return redirect()->route('customer.session.index');
}
}

View File

@ -32,6 +32,11 @@ class VerificationEmail extends Mailable
{
return $this->to($this->verificationData['email'])
->subject(trans('shop::app.mail.customer.verification.subject'))
->view('shop::emails.customer.verification-email')->with('data', ['email' => $this->verificationData['email'], 'token' => $this->verificationData['token']]);
->view('shop::emails.customer.verification-email')
->with('data', [
'email' => $this->verificationData['email'],
'token' => $this->verificationData['token'],
]
);
}
}

View File

@ -17,21 +17,38 @@ class Customer extends Authenticatable implements CustomerContract, JWTSubject
protected $table = 'customers';
protected $fillable = ['first_name', 'last_name', 'gender', 'date_of_birth', 'email', 'phone', 'password', 'api_token', 'customer_group_id', 'subscribed_to_news_letter', 'is_verified', 'token', 'notes', 'status'];
protected $fillable = [
'first_name',
'last_name',
'gender',
'date_of_birth',
'email',
'phone',
'password',
'api_token',
'customer_group_id',
'subscribed_to_news_letter',
'is_verified',
'token',
'notes',
'status',
];
protected $hidden = ['password', 'api_token', 'remember_token'];
/**
* Get the customer full name.
*/
public function getNameAttribute() {
public function getNameAttribute()
{
return ucfirst($this->first_name) . ' ' . ucfirst($this->last_name);
}
/**
* Email exists or not
*/
public function emailExists($email) {
public function emailExists($email)
{
$results = $this->where('email', $email);
if ($results->count() == 0) {
@ -79,42 +96,48 @@ class Customer extends Authenticatable implements CustomerContract, JWTSubject
/**
* Customer's relation with wishlist items
*/
public function wishlist_items() {
public function wishlist_items()
{
return $this->hasMany(WishlistProxy::modelClass(), 'customer_id');
}
/**
* get all cart inactive cart instance of a customer
*/
public function all_carts() {
public function all_carts()
{
return $this->hasMany(CartProxy::modelClass(), 'customer_id');
}
/**
* get inactive cart inactive cart instance of a customer
*/
public function inactive_carts() {
public function inactive_carts()
{
return $this->hasMany(CartProxy::modelClass(), 'customer_id')->where('is_active', 0);
}
/**
* get active cart inactive cart instance of a customer
*/
public function active_carts() {
public function active_carts()
{
return $this->hasMany(CartProxy::modelClass(), 'customer_id')->where('is_active', 1);
}
/**
* get all reviews of a customer
*/
public function all_reviews() {
public function all_reviews()
{
return $this->hasMany(ProductReviewProxy::modelClass(), 'customer_id');
}
/**
* get all orders of a customer
*/
public function all_orders() {
public function all_orders()
{
return $this->hasMany(OrderProxy::modelClass(), 'customer_id');
}

View File

@ -14,7 +14,15 @@ class Wishlist extends Model implements WishlistContract
'additional' => 'array',
];
protected $fillable = ['channel_id', 'product_id', 'customer_id', 'additional', 'moved_to_cart', 'shared', 'time_of_moving'];
protected $fillable = [
'channel_id',
'product_id',
'customer_id',
'additional',
'moved_to_cart',
'shared',
'time_of_moving'
];
/**
* The Product that belong to the wishlist.

View File

@ -25,6 +25,7 @@ class CustomerResetPassword extends ResetPassword
->view('shop::emails.customer.forget-password', [
'user_name' => $notifiable->name,
'token' => $this->token
]);
]
);
}
}

View File

@ -169,6 +169,7 @@ class InventorySourceController extends Controller
return response()->json(['message' => true], 200);
} catch (\Exception $e) {
report($e);
session()->flash('error', trans('admin::app.response.delete-failed', ['name' => 'Inventory source']));
}
}

View File

@ -74,7 +74,7 @@ class PriceUpdate extends Command
->distinct()
->leftJoin('products', 'product_flat.product_id', 'products.id')
->leftJoin('product_bundle_options', 'products.id', 'product_bundle_options.product_id')
->leftJoin('product_bundle_option_products', 'product_bundle_options.id', 'product_bundle_option_products.product_bundle_option_id')
->leftJoin('product_bundle_option_products', 'product_bundle_options.id', 'product_bundle_option_productsproduct_bundle_option_id')
->where('product_bundle_option_products.product_id', $product->product_id)
->get();

View File

@ -246,6 +246,7 @@ class ProductController extends Controller
return response()->json(['message' => true], 200);
} catch (\Exception $e) {
report($e);
session()->flash('error', trans('admin::app.response.delete-failed', ['name' => 'Product']));
}

View File

@ -140,10 +140,11 @@ class ReviewController extends Controller
}
}
if (! $suppressFlash)
if (! $suppressFlash) {
session()->flash('success', trans('admin::app.datagrid.mass-ops.delete-success', ['resource' => 'Reviews']));
else
} else {
session()->flash('info', trans('admin::app.datagrid.mass-ops.partial-action', ['resource' => 'Reviews']));
}
return redirect()->route($this->_config['redirect']);
@ -194,10 +195,11 @@ class ReviewController extends Controller
}
}
if (! $suppressFlash)
if (! $suppressFlash) {
session()->flash('success', trans('admin::app.datagrid.mass-ops.update-success', ['resource' => 'Reviews']));
else
} else {
session()->flash('info', trans('admin::app.datagrid.mass-ops.partial-action', ['resource' => 'Reviews']));
}
return redirect()->route($this->_config['redirect']);
} else {

View File

@ -223,9 +223,16 @@ class ProductFlat
if ($attribute->value_per_channel) {
if ($attribute->value_per_locale) {
$productAttributeValue = $product->attribute_values()->where('channel', $channel->code)->where('locale', $locale->code)->where('attribute_id', $attribute->id)->first();
$productAttributeValue = $product->attribute_values()
->where('channel', $channel->code)
->where('locale', $locale->code)
->where('attribute_id', $attribute->id)
->first();
} else {
$productAttributeValue = $product->attribute_values()->where('channel', $channel->code)->where('attribute_id', $attribute->id)->first();
$productAttributeValue = $product->attribute_values()
->where('channel', $channel->code)
->where('attribute_id', $attribute->id)
->first();
}
} else {
if ($attribute->value_per_locale) {

View File

@ -9,7 +9,14 @@ class ProductBundleOptionProduct extends Model implements ProductBundleOptionPro
{
public $timestamps = false;
protected $fillable = ['qty', 'is_user_defined', 'sort_order', 'is_default', 'product_bundle_option_id', 'product_id'];
protected $fillable = [
'qty',
'is_user_defined',
'sort_order',
'is_default',
'product_bundle_option_id',
'product_id',
];
/**
* Get the bundle option that owns this resource.

View File

@ -10,7 +10,21 @@ class ProductDownloadableLink extends TranslatableModel implements ProductDownlo
{
public $translatedAttributes = ['title'];
protected $fillable = ['title', 'price', 'url', 'file', 'file_name', 'type', 'sample_url', 'sample_file', 'sample_file_name', 'sample_type', 'sort_order', 'product_id', 'downloads'];
protected $fillable = [
'title',
'price',
'url',
'file',
'file_name',
'type',
'sample_url',
'sample_file',
'sample_file_name',
'sample_type',
'sort_order',
'product_id',
'downloads',
];
protected $with = ['translations'];

View File

@ -9,7 +9,15 @@ use Webkul\Product\Contracts\ProductReview as ProductReviewContract;
class ProductReview extends Model implements ProductReviewContract
{
protected $fillable = ['comment', 'title', 'rating', 'status', 'product_id', 'customer_id', 'name'];
protected $fillable = [
'comment',
'title',
'rating',
'status',
'product_id',
'customer_id',
'name',
];
/**
* Get the product attribute family that owns the product.

View File

@ -49,13 +49,11 @@ class ProductFlatRepository extends Repository
->where('product_flat.channel', core()->getCurrentChannelCode())
->where('product_flat.locale', app()->getLocale());
$productArrributes = $qb
->leftJoin('product_attribute_values as pa', 'product_flat.product_id', 'pa.product_id')
$productArrributes = $qb->leftJoin('product_attribute_values as pa', 'product_flat.product_id', 'pa.product_id')
->pluck('pa.attribute_id')
->toArray();
$productSuperArrributes = $qb
->leftJoin('product_super_attributes as ps', 'product_flat.product_id', 'ps.product_id')
$productSuperArrributes = $qb->leftJoin('product_super_attributes as ps', 'product_flat.product_id', 'ps.product_id')
->pluck('ps.attribute_id')
->toArray();

View File

@ -237,7 +237,8 @@ class Bundle extends AbstractType
$optionPrices[] = $bundleOptionProduct->qty
* ($minPrice
? $bundleOptionProduct->product->getTypeInstance()->getMinimalPrice()
: $bundleOptionProduct->product->price);
: $bundleOptionProduct->product->price
);
}
return $optionPrices;

View File

@ -147,6 +147,7 @@ class Configurable extends AbstractType
$typeOfVariants = 'simple';
$productInstance = app(config('product_types.' . $product->type . '.class'));
if (isset($productInstance->variantsType) && ! in_array($productInstance->variantsType , ['bundle', 'configurable', 'grouped'])) {
$typeOfVariants = $productInstance->variantsType;
}

View File

@ -39,10 +39,11 @@ class Validator
$validConditionCount++;
}
} else {
if ($this->validateObject($condition, $entity))
if ($this->validateObject($condition, $entity)) {
return true;
}
}
}
return $validConditionCount == $totalConditionCount ? true : false;
}

View File

@ -11,7 +11,20 @@ class DownloadableLinkPurchased extends Model implements DownloadableLinkPurchas
{
protected $table = 'downloadable_link_purchased';
protected $fillable = ['product_name', 'name', 'url', 'file', 'file_name', 'type', 'download_bought', 'download_used', 'status', 'customer_id', 'order_id', 'order_item_id'];
protected $fillable = [
'product_name',
'name',
'url',
'file',
'file_name',
'type',
'download_bought',
'download_used',
'status',
'customer_id',
'order_id',
'order_item_id',
];
/**
* Get the customer record associated with the item.

View File

@ -65,6 +65,7 @@ class DownloadableProductController extends Controller
if ($downloadableLinkPurchased->download_bought
&& ($downloadableLinkPurchased->download_bought - $downloadableLinkPurchased->download_used) <= 0) {
session()->flash('warning', trans('shop::app.customer.account.downloadable_products.download-error'));
return redirect()->route('customer.downloadable_products.index');

View File

@ -32,7 +32,12 @@ class SubscriptionEmail extends Mailable
{
return $this->to($this->subscriptionData['email'])
->subject(trans('shop::app.mail.customer.subscription.subject'))
->view('shop::emails.customer.subscription-email')->with('data', ['content' => 'You Are Subscribed', 'token' => $this->subscriptionData['token']]);
->view('shop::emails.customer.subscription-email')
->with('data', [
'content' => 'You Are Subscribed',
'token' => $this->subscriptionData['token']
]
);
}
}

View File

@ -16,12 +16,14 @@ class Tax
public static function getTaxRatesWithAmount(object $that, bool $asBase = false): array
{
$taxes = [];
foreach ($that->items as $item) {
$taxRate = (string) round((float) $item->tax_percent, self::TAX_PRECISION);
if (! array_key_exists($taxRate, $taxes)) {
$taxes[$taxRate] = 0;
}
$taxes[$taxRate] += $asBase ? $item->base_tax_amount : $item->tax_amount;
}
@ -40,9 +42,11 @@ class Tax
$taxes = self::getTaxRatesWithAmount($that, $asBase);
$result = 0;
foreach ($taxes as $taxRate => $taxAmount) {
$result += round($taxAmount, 2);
}
return $result;
}
}

View File

@ -16,11 +16,15 @@ class TaxCategory extends Model implements TaxCategoryContract
protected $table = 'tax_categories';
protected $fillable = [
'channel_id' ,'code', 'name' ,'description'
'channel_id',
'code',
'name',
'description',
];
//for joining the two way pivot table
public function tax_rates() {
public function tax_rates()
{
return $this->belongsToMany(TaxRateProxy::modelClass(), 'tax_categories_tax_rates', 'tax_category_id')->withPivot('id');
}
}

View File

@ -18,7 +18,8 @@ class TaxMap extends Model implements TaxMapContract
protected $table = 'tax_categories_tax_rates';
protected $fillable = [
'tax_category_id', 'tax_rate_id'
'tax_category_id',
'tax_rate_id',
];
}

View File

@ -17,10 +17,19 @@ class TaxRate extends Model implements TaxRateContract
protected $table = 'tax_rates';
protected $fillable = [
'identifier', 'is_zip', 'zip_code', 'zip_code', 'zip_from', 'zip_to', 'state', 'country', 'tax_rate'
'identifier',
'is_zip',
'zip_code',
'zip_code',
'zip_from',
'zip_to',
'state',
'country',
'tax_rate'
];
public function tax_categories() {
public function tax_categories()
{
return $this->belongsToMany(TaxCategoryProxy::modelClass(), 'tax_categories_tax_rates', 'tax_rate_id', 'id');
}
}

View File

@ -2,9 +2,10 @@
namespace Webkul\Theme\Exceptions;
class ThemeAlreadyExists extends \Exception {
public function __construct($theme) {
class ThemeAlreadyExists extends \Exception
{
public function __construct($theme)
{
parent::__construct("Theme {$theme->name} already exists", 1);
}
}

View File

@ -1,8 +1,9 @@
<?php namespace Webkul\Theme\Exceptions;
class ThemeNotFound extends \Exception {
public function __construct($themeName) {
class ThemeNotFound extends \Exception
{
public function __construct($themeName)
{
parent::__construct("Theme $themeName not Found", 1);
}
}

View File

@ -322,7 +322,6 @@ abstract class DataGrid
if ($count_keys == 1) {
$collection->where(function($collection) use($info) {
foreach ($this->completeColumnDetails as $column) {
if ($column['searchable'] == true) {
if($this->enableFilterMap && isset($this->filterMap[$column['index']])) {
$collection->orWhere($this->filterMap[$column['index']], 'like', '%'.$info['all'].'%');

View File

@ -19,7 +19,12 @@ class Admin extends Authenticatable implements AdminContract
* @var array
*/
protected $fillable = [
'name', 'email', 'password', 'api_token', 'role_id', 'status',
'name',
'email',
'password',
'api_token',
'role_id',
'status',
];
/**
@ -28,7 +33,9 @@ class Admin extends Authenticatable implements AdminContract
* @var array
*/
protected $hidden = [
'password', 'api_token', 'remember_token',
'password',
'api_token',
'remember_token',
];
/**

View File

@ -15,7 +15,10 @@ class Role extends Model implements RoleContract
* @var array
*/
protected $fillable = [
'name', 'description', 'permission_type', 'permissions',
'name',
'description',
'permission_type',
'permissions',
];
protected $casts = [

View File

@ -148,7 +148,8 @@ class Helper extends Review
*/
public function getCountRating($product)
{
$reviews = $product->reviews()->where('status', 'approved')
$reviews = $product->reviews()
->where('status', 'approved')
->select('rating', DB::raw('count(*) as total'))
->groupBy('rating')
->orderBy('rating','desc')

View File

@ -10,7 +10,16 @@ class Content extends TranslatableModel implements ContentContract
protected $table = 'velocity_contents';
public $translatedAttributes = ['title', 'custom_title', 'custom_heading', 'page_link', 'link_target', 'catalog_type', 'products', 'description'];
public $translatedAttributes = [
'title',
'custom_title',
'custom_heading',
'page_link',
'link_target',
'catalog_type',
'products',
'description'
];
protected $fillable = ['content_type', 'position', 'status'];

View File

@ -12,7 +12,16 @@ class ContentTranslation extends Model implements ContentTranslationContract
public $timestamps = false;
protected $fillable = ['title', 'custom_title', 'custom_heading', 'page_link', 'link_target', 'catalog_type', 'products', 'description'];
protected $fillable = [
'title',
'custom_title',
'custom_heading',
'page_link',
'link_target',
'catalog_type',
'products',
'description'
];
public function content()
{

View File

@ -14,7 +14,8 @@ class OrderBrands extends Model implements OrderBrandContract
protected $fillable = ['order_item_id','order_id','product_id','brand'];
public function getBrands() {
public function getBrands()
{
return $this->belongsTo(AttributeOptionProxy::modelClass() , 'brand');
}