Skip to content

Commit

Permalink
Merge pull request #57 from avored/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
indpurvesh authored Dec 21, 2018
2 parents 609567c + 82406be commit 50567dc
Show file tree
Hide file tree
Showing 21 changed files with 237 additions and 134 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -401,8 +401,8 @@ public function up()

Schema::create('users', function(Blueprint $table) {
$table->increments('id');
$table->string('first_name');
$table->string('last_name');
$table->string('first_name')->nullable()->default(null);
$table->string('last_name')->nullable()->default(null);
$table->string('email')->unique();
$table->string('password');
$table->string('image_path')->nullable();
Expand All @@ -411,6 +411,7 @@ public function up()
$table->enum('status', ['GUEST', 'LIVE'])->default('LIVE');
$table->string('tax_no')->nullable()->default(null);
$table->timestamp('email_verified_at')->nullable();
$table->enum('registered_channel', ['WEBSITE', 'FACEBOOK', 'TWITTER', 'GOOGLE'])->default('WEBSITE');
$table->rememberToken();
$table->timestamps();
});
Expand Down
5 changes: 2 additions & 3 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"

processIsolation="true"
stopOnFailure="true"
>
<testsuites>
<testsuite name="AvoRed Framework Tests">
Expand Down
1 change: 1 addition & 0 deletions resources/sass/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
@import 'spec/index';
@import 'vendor/index';
@import '~simplemde/dist/simplemde.min.css';
@import "~select2/src/scss/core";

.card-header {
color: $white;
Expand Down
1 change: 0 additions & 1 deletion resources/sass/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@
@import "~bootstrap/scss/bootstrap";
@import 'spec/index';
@import 'vendor/index';

41 changes: 29 additions & 12 deletions resources/views/user/user/_fields.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,35 @@
@include('avored-framework::forms.text',['name' => 'first_name' ,'label' => __('avored-framework::user.first-name')])
@include('avored-framework::forms.text',['name' => 'last_name' ,'label' => __('avored-framework::user.last-name')])

@include('avored-framework::forms.text',['name' => 'email' ,'label' => __('avored-framework::user.email')])

@include('avored-framework::forms.select2',[
'name' => 'user_group_id[]' ,
'label' => __('avored-framework::user.user-group-id'),
'values' => [],
'options'=> $userGroupOptions,
'attributes' => [
'multiple' => true,
'class' => 'form-control select2',
'id' => 'user_group_id'
]
])
@if (!isset($model))

@include('avored-framework::forms.password',['name' => 'password' ,'label' => __('avored-framework::user.password')])
@include('avored-framework::forms.password',['name' => 'confirm_password' ,'label' => __('avored-framework::user.confirm-password')])

@endif

@php
if (isset($model)) {
$values = $model->userGroups->pluck('id')->toArray();
} else {
$values = [];
}
@endphp
@include(
'avored-framework::forms.select2',
[
'name' => 'user_group_id[]' ,
'label' => __('avored-framework::user.user-group-id'),
'values' => $values,
'options'=> $userGroupOptions,
'attributes' => [
'multiple' => true,
'class' => 'form-control select2',
'id' => 'user_group_id'
]
]
)


87 changes: 51 additions & 36 deletions src/AdminConfiguration/Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ public function boot()
public function register()
{
$this->registerManager();
$this->app->singleton('adminconfiguration', \AvoRed\Framework\AdminConfiguration\Manager::class);
$this->app->singleton(
'adminconfiguration',
\AvoRed\Framework\AdminConfiguration\Manager::class
);
}

/**
Expand All @@ -45,9 +48,12 @@ public function register()
*/
protected function registerManager()
{
$this->app->singleton('adminconfiguration', function () {
new Manager();
});
$this->app->singleton(
'adminconfiguration',
function () {
new Manager();
}
);
}

/**
Expand Down Expand Up @@ -96,19 +102,22 @@ protected function registerAdminConfiguration()
->label('Term & Condition Page')
->type('select')
->name('general_term_condition_page')
->options(function () {
$options = Page::all()->pluck('name', 'id');
return $options;
});
->options(
function () {
$options = Page::all()->pluck('name', 'id');
return $options;
}
);

$configurationGroup->addConfiguration('general_home_page')
->label('Home Page')
->type('select')
->name('general_home_page')
->options(function () {
$options = Page::all()->pluck('name', 'id');
return $options;
});
->options(
function () {
return Page::all()->pluck('name', 'id');
}
);

$userGroup = AdminConfigurationFacade::add('users')
->label('Users');
Expand All @@ -117,19 +126,21 @@ protected function registerAdminConfiguration()
->label('User Default Country')
->type('select')
->name('user_default_country')
->options(function () {
$options = Country::all()->pluck('name', 'id');
return $options;
});
->options(
function () {
return Country::all()->pluck('name', 'id');
}
);

$userGroup->addConfiguration('user_activation_required')
->label('User Activation Required')
->type('select')
->name('user_activation_required')
->options(function () {
$options = [0 => 'No', 1 => 'Yes'];
return $options;
});
->options(
function () {
return [0 => 'No', 1 => 'Yes'];
}
);

$shippingGroup = AdminConfigurationFacade::add('shipping')
->label('Shipping');
Expand All @@ -138,10 +149,11 @@ protected function registerAdminConfiguration()
->label('Is Free Shipping Enabled')
->type('select')
->name('shipping_free_shipping_enabled')
->options(function () {
$options = [1 => 'Yes', 0 => 'No'];
return $options;
});
->options(
function () {
return [1 => 'Yes', 0 => 'No'];
}
);

$paymentGroup = AdminConfigurationFacade::add('payment')
->label('Payment');
Expand All @@ -150,10 +162,11 @@ protected function registerAdminConfiguration()
->label('Payment Stripe Enabled')
->type('select')
->name('payment_stripe_enabled')
->options(function () {
$options = [0 => 'No', 1 => 'Yes'];
return $options;
});
->options(
function () {
return [0 => 'No', 1 => 'Yes'];
}
);

$paymentGroup->addConfiguration('payment_stripe_publishable_key')
->label('Payment Stripe Publishable Key')
Expand All @@ -172,10 +185,11 @@ protected function registerAdminConfiguration()
->label('Is Tax Enabled')
->type('select')
->name('tax_enabled')
->options(function () {
$options = [1 => 'Yes', 0 => 'No'];
return $options;
});
->options(
function () {
return [1 => 'Yes', 0 => 'No'];
}
);

$taxGroup->addConfiguration('tax_percentage')
->label('Tax Percentage')
Expand All @@ -186,9 +200,10 @@ protected function registerAdminConfiguration()
->label('Tax Default Country')
->type('select')
->name('tax_default_country')
->options(function () {
$options = $options = Country::all()->pluck('name', 'id');
return $options;
});
->options(
function () {
return $options = Country::all()->pluck('name', 'id');
}
);
}
}
40 changes: 28 additions & 12 deletions src/Cart/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,28 @@ public function add($slug, $qty, $attribute = null): Manager
$attributes = null;

if (null !== $attribute && count($attribute)) {
foreach ($attribute as $attributeId => $variationId) {
$variableProduct = Product::find($variationId);

foreach ($attribute as $attributeId => $attributeValueId) {
if ('variation_id' == $attributeId) {
continue;
}
$variableProduct = Product::find($attribute['variation_id']);
$attributeModel = Attribute::find($attributeId);

$productAttributeIntValModel = ProductAttributeIntegerValue::
whereAttributeId($attributeId)
->whereProductId($variableProduct->id)
->first();
whereAttributeId($attributeId)
->whereProductId($variableProduct->id)
->first();

$optionModel = $attributeModel
->AttributeDropdownOptions()
->whereId($productAttributeIntValModel->value)
->first();
->AttributeDropdownOptions()
->whereId($productAttributeIntValModel->value)
->first();

$price = $variableProduct->price;
$attributes[] = [
'attribute_id' => $attributeId,
'variation_id' => $variationId,
'variation_id' => $variableProduct->id,
'attribute_dropdown_option_id' => $optionModel->id,
'variation_display_text' => $attributeModel->name . ': ' . $optionModel->display_text
];
Expand Down Expand Up @@ -97,11 +102,22 @@ public function canAddToCart($slug, $qty, $attribute = [])
$cartProducts = $this->getSession();
$cartProduct = $cartProducts->get($slug);
$cartQty = $cartProduct ? $cartProduct->qty() : 0;

$checkQty = $qty + $cartQty;
$checkQty = $qty;

$product = Product::whereSlug($slug)->first();
if ($product->hasVariation()) {

$productQty = $product->qty;
$findVaritationId = false;
foreach ($attribute['attributes'] as $attributeId => $attributeInfo) {
if (false === $findVaritationId && (isset($attributeInfo['variation_id']))) {
$variationId = $attributeInfo['variation_id'];
}

}
$product = Product::find($variationId);
}

$productQty = $product->qty;
if ($productQty >= $checkQty) {
return true;
}
Expand Down
Loading

0 comments on commit 50567dc

Please sign in to comment.