Skip to content

Commit 50567dc

Browse files
authored
Merge pull request #57 from avored/dev
Dev
2 parents 609567c + 82406be commit 50567dc

File tree

21 files changed

+237
-134
lines changed

21 files changed

+237
-134
lines changed

database/migrations/2017_03_29_000000_avored_framework_schema.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -401,8 +401,8 @@ public function up()
401401

402402
Schema::create('users', function(Blueprint $table) {
403403
$table->increments('id');
404-
$table->string('first_name');
405-
$table->string('last_name');
404+
$table->string('first_name')->nullable()->default(null);
405+
$table->string('last_name')->nullable()->default(null);
406406
$table->string('email')->unique();
407407
$table->string('password');
408408
$table->string('image_path')->nullable();
@@ -411,6 +411,7 @@ public function up()
411411
$table->enum('status', ['GUEST', 'LIVE'])->default('LIVE');
412412
$table->string('tax_no')->nullable()->default(null);
413413
$table->timestamp('email_verified_at')->nullable();
414+
$table->enum('registered_channel', ['WEBSITE', 'FACEBOOK', 'TWITTER', 'GOOGLE'])->default('WEBSITE');
414415
$table->rememberToken();
415416
$table->timestamps();
416417
});

phpunit.xml

+2-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
convertErrorsToExceptions="true"
66
convertNoticesToExceptions="true"
77
convertWarningsToExceptions="true"
8-
processIsolation="false"
9-
stopOnFailure="false"
10-
8+
processIsolation="true"
9+
stopOnFailure="true"
1110
>
1211
<testsuites>
1312
<testsuite name="AvoRed Framework Tests">

resources/sass/app.scss

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
@import 'spec/index';
55
@import 'vendor/index';
66
@import '~simplemde/dist/simplemde.min.css';
7+
@import "~select2/src/scss/core";
78

89
.card-header {
910
color: $white;

resources/sass/index.scss

-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@
33
@import "~bootstrap/scss/bootstrap";
44
@import 'spec/index';
55
@import 'vendor/index';
6-

resources/views/user/user/_fields.blade.php

+29-12
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,35 @@
22
@include('avored-framework::forms.text',['name' => 'first_name' ,'label' => __('avored-framework::user.first-name')])
33
@include('avored-framework::forms.text',['name' => 'last_name' ,'label' => __('avored-framework::user.last-name')])
44

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

6-
@include('avored-framework::forms.select2',[
7-
'name' => 'user_group_id[]' ,
8-
'label' => __('avored-framework::user.user-group-id'),
9-
'values' => [],
10-
'options'=> $userGroupOptions,
11-
'attributes' => [
12-
'multiple' => true,
13-
14-
'class' => 'form-control select2',
15-
'id' => 'user_group_id'
16-
]
17-
])
7+
@if (!isset($model))
8+
9+
@include('avored-framework::forms.password',['name' => 'password' ,'label' => __('avored-framework::user.password')])
10+
@include('avored-framework::forms.password',['name' => 'confirm_password' ,'label' => __('avored-framework::user.confirm-password')])
11+
12+
@endif
13+
14+
@php
15+
if (isset($model)) {
16+
$values = $model->userGroups->pluck('id')->toArray();
17+
} else {
18+
$values = [];
19+
}
20+
@endphp
21+
@include(
22+
'avored-framework::forms.select2',
23+
[
24+
'name' => 'user_group_id[]' ,
25+
'label' => __('avored-framework::user.user-group-id'),
26+
'values' => $values,
27+
'options'=> $userGroupOptions,
28+
'attributes' => [
29+
'multiple' => true,
30+
'class' => 'form-control select2',
31+
'id' => 'user_group_id'
32+
]
33+
]
34+
)
1835

1936

src/AdminConfiguration/Provider.php

+51-36
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ public function boot()
3535
public function register()
3636
{
3737
$this->registerManager();
38-
$this->app->singleton('adminconfiguration', \AvoRed\Framework\AdminConfiguration\Manager::class);
38+
$this->app->singleton(
39+
'adminconfiguration',
40+
\AvoRed\Framework\AdminConfiguration\Manager::class
41+
);
3942
}
4043

4144
/**
@@ -45,9 +48,12 @@ public function register()
4548
*/
4649
protected function registerManager()
4750
{
48-
$this->app->singleton('adminconfiguration', function () {
49-
new Manager();
50-
});
51+
$this->app->singleton(
52+
'adminconfiguration',
53+
function () {
54+
new Manager();
55+
}
56+
);
5157
}
5258

5359
/**
@@ -96,19 +102,22 @@ protected function registerAdminConfiguration()
96102
->label('Term & Condition Page')
97103
->type('select')
98104
->name('general_term_condition_page')
99-
->options(function () {
100-
$options = Page::all()->pluck('name', 'id');
101-
return $options;
102-
});
105+
->options(
106+
function () {
107+
$options = Page::all()->pluck('name', 'id');
108+
return $options;
109+
}
110+
);
103111

104112
$configurationGroup->addConfiguration('general_home_page')
105113
->label('Home Page')
106114
->type('select')
107115
->name('general_home_page')
108-
->options(function () {
109-
$options = Page::all()->pluck('name', 'id');
110-
return $options;
111-
});
116+
->options(
117+
function () {
118+
return Page::all()->pluck('name', 'id');
119+
}
120+
);
112121

113122
$userGroup = AdminConfigurationFacade::add('users')
114123
->label('Users');
@@ -117,19 +126,21 @@ protected function registerAdminConfiguration()
117126
->label('User Default Country')
118127
->type('select')
119128
->name('user_default_country')
120-
->options(function () {
121-
$options = Country::all()->pluck('name', 'id');
122-
return $options;
123-
});
129+
->options(
130+
function () {
131+
return Country::all()->pluck('name', 'id');
132+
}
133+
);
124134

125135
$userGroup->addConfiguration('user_activation_required')
126136
->label('User Activation Required')
127137
->type('select')
128138
->name('user_activation_required')
129-
->options(function () {
130-
$options = [0 => 'No', 1 => 'Yes'];
131-
return $options;
132-
});
139+
->options(
140+
function () {
141+
return [0 => 'No', 1 => 'Yes'];
142+
}
143+
);
133144

134145
$shippingGroup = AdminConfigurationFacade::add('shipping')
135146
->label('Shipping');
@@ -138,10 +149,11 @@ protected function registerAdminConfiguration()
138149
->label('Is Free Shipping Enabled')
139150
->type('select')
140151
->name('shipping_free_shipping_enabled')
141-
->options(function () {
142-
$options = [1 => 'Yes', 0 => 'No'];
143-
return $options;
144-
});
152+
->options(
153+
function () {
154+
return [1 => 'Yes', 0 => 'No'];
155+
}
156+
);
145157

146158
$paymentGroup = AdminConfigurationFacade::add('payment')
147159
->label('Payment');
@@ -150,10 +162,11 @@ protected function registerAdminConfiguration()
150162
->label('Payment Stripe Enabled')
151163
->type('select')
152164
->name('payment_stripe_enabled')
153-
->options(function () {
154-
$options = [0 => 'No', 1 => 'Yes'];
155-
return $options;
156-
});
165+
->options(
166+
function () {
167+
return [0 => 'No', 1 => 'Yes'];
168+
}
169+
);
157170

158171
$paymentGroup->addConfiguration('payment_stripe_publishable_key')
159172
->label('Payment Stripe Publishable Key')
@@ -172,10 +185,11 @@ protected function registerAdminConfiguration()
172185
->label('Is Tax Enabled')
173186
->type('select')
174187
->name('tax_enabled')
175-
->options(function () {
176-
$options = [1 => 'Yes', 0 => 'No'];
177-
return $options;
178-
});
188+
->options(
189+
function () {
190+
return [1 => 'Yes', 0 => 'No'];
191+
}
192+
);
179193

180194
$taxGroup->addConfiguration('tax_percentage')
181195
->label('Tax Percentage')
@@ -186,9 +200,10 @@ protected function registerAdminConfiguration()
186200
->label('Tax Default Country')
187201
->type('select')
188202
->name('tax_default_country')
189-
->options(function () {
190-
$options = $options = Country::all()->pluck('name', 'id');
191-
return $options;
192-
});
203+
->options(
204+
function () {
205+
return $options = Country::all()->pluck('name', 'id');
206+
}
207+
);
193208
}
194209
}

src/Cart/Manager.php

+28-12
Original file line numberDiff line numberDiff line change
@@ -45,23 +45,28 @@ public function add($slug, $qty, $attribute = null): Manager
4545
$attributes = null;
4646

4747
if (null !== $attribute && count($attribute)) {
48-
foreach ($attribute as $attributeId => $variationId) {
49-
$variableProduct = Product::find($variationId);
48+
49+
foreach ($attribute as $attributeId => $attributeValueId) {
50+
if ('variation_id' == $attributeId) {
51+
continue;
52+
}
53+
$variableProduct = Product::find($attribute['variation_id']);
5054
$attributeModel = Attribute::find($attributeId);
5155

5256
$productAttributeIntValModel = ProductAttributeIntegerValue::
53-
whereAttributeId($attributeId)
54-
->whereProductId($variableProduct->id)
55-
->first();
57+
whereAttributeId($attributeId)
58+
->whereProductId($variableProduct->id)
59+
->first();
60+
5661
$optionModel = $attributeModel
57-
->AttributeDropdownOptions()
58-
->whereId($productAttributeIntValModel->value)
59-
->first();
62+
->AttributeDropdownOptions()
63+
->whereId($productAttributeIntValModel->value)
64+
->first();
6065

6166
$price = $variableProduct->price;
6267
$attributes[] = [
6368
'attribute_id' => $attributeId,
64-
'variation_id' => $variationId,
69+
'variation_id' => $variableProduct->id,
6570
'attribute_dropdown_option_id' => $optionModel->id,
6671
'variation_display_text' => $attributeModel->name . ': ' . $optionModel->display_text
6772
];
@@ -97,11 +102,22 @@ public function canAddToCart($slug, $qty, $attribute = [])
97102
$cartProducts = $this->getSession();
98103
$cartProduct = $cartProducts->get($slug);
99104
$cartQty = $cartProduct ? $cartProduct->qty() : 0;
100-
101-
$checkQty = $qty + $cartQty;
105+
$checkQty = $qty;
106+
102107
$product = Product::whereSlug($slug)->first();
108+
if ($product->hasVariation()) {
103109

104-
$productQty = $product->qty;
110+
$findVaritationId = false;
111+
foreach ($attribute['attributes'] as $attributeId => $attributeInfo) {
112+
if (false === $findVaritationId && (isset($attributeInfo['variation_id']))) {
113+
$variationId = $attributeInfo['variation_id'];
114+
}
115+
116+
}
117+
$product = Product::find($variationId);
118+
}
119+
120+
$productQty = $product->qty;
105121
if ($productQty >= $checkQty) {
106122
return true;
107123
}

0 commit comments

Comments
 (0)