Skip to content

Commit

Permalink
Merge pull request #125 from avored/developed
Browse files Browse the repository at this point in the history
3.1.1
  • Loading branch information
indpurvesh authored Aug 18, 2020
2 parents e52ceef + 0613885 commit 5ecf30a
Show file tree
Hide file tree
Showing 20 changed files with 133 additions and 83 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --https --key ~/.config/valet/Certificates/laravel-ecommerce.test.key --cert ~/.config/valet/Certificates/laravel-ecommerce.test.crt --config=node_modules/laravel-mix/setup/webpack.config.js"
},
"dependencies": {
"avored-components": "^0.1.5",
"avored-components": "^0.1.6",
"axios": "^0.19.2",
"cross-env": "^7.0.2",
"laravel-mix": "^5.0.4",
Expand Down
2 changes: 1 addition & 1 deletion resources/components/catalog/category/CategoryTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export default {
var url = this.baseUrl + '/category/' + record.id;
var app = this;
this.$confirm({message: `Do you Want to delete ${record.name} category?`, callback: () => {
axios.delete(url)
axios.delete(url)
.then(response => {
if (response.data.success === true) {
app.$alert(response.data.message)
Expand Down
38 changes: 22 additions & 16 deletions resources/components/cms/page/PageSave.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,39 @@ export default {
content: '',
widgetModalVisible: false,
selectedWidget: '',
toolbar: null,
editor: null,
widgetModalVisible: false,
configs: {
toolbar: [
'bold',
'italic',
'heading', '|', 'quote', 'unordered-list', 'ordered-list', '|', 'image', 'link', '|', 'table', 'preview', '|', 'side-by-side',
{
name: 'custom',
action: this.widgetClick,
className: 'fa fa-star',
title: 'Widget'
}
]
}
};
},
methods: {
handleSubmit() {
this.pageForm.validateFields((err, values) => {
if (err) {
e.preventDefault();
}
});
},
cancelPage() {
window.location = this.baseUrl + '/page';
},
widgetClick(toolbar) {
this.toolbar = toolbar
widgetClick(editor) {
this.editor = editor
this.widgetModalVisible = true
},
handleWidgetOk() {
//
var cm = this.editor.codemirror
var output = '%%%' + this.selectedWidget + '%%%'
cm.replaceSelection(output)
this.widgetModalVisible = false
this.widgetModalVisible = false
}
},
mounted() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,11 @@ export default {
props: ['baseUrl'],
data () {
return {
configurationForm: this.$form.createForm(this)
};
},
methods: {
handleSubmit(e) {
this.configurationForm.validateFields((err, values) => {
if (err) {
e.preventDefault();
}
});
},
cancelConfiguration() {
window.location = this.baseUrl + '/configuration';
Expand Down
3 changes: 2 additions & 1 deletion resources/lang/en/system.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@
],
'basic' => [
'site_name' => 'Site Name',
'default_currency' => 'Default Currency'
],
'user' => [
'user_name' => 'Username',
Expand Down Expand Up @@ -561,4 +562,4 @@
],
],

];
];
4 changes: 4 additions & 0 deletions resources/sass/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@
@tailwind components;

@tailwind utilities;

.CodeMirror {
z-index: 0 !important;
}
23 changes: 11 additions & 12 deletions resources/views/cms/page/_fields.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,16 @@



<div class="ant-row ant-form-item">
<div class="ant-form-item-label">
<label for="page-content" title="{{ __('avored::cms.page.content') }}">
<div class="mt-3">
<div class="">
<label class="block text-sm leading-5 text-gray-500"
for="page-content" title="{{ __('avored::cms.page.content') }}">
{{ __('avored::cms.page.content') }}
</label>
</div>

<div class="ant-form-item-control-wrapper">
<div class="ant-form-item-control">
<vue-simplemde name="content" v-model="content" ref="markdownEditor" />
</div>
<div class="mt-1">
<vue-simplemde name="content" :configs="configs" v-model="content" ref="markdownEditor" />
</div>
</div>

Expand All @@ -38,7 +37,7 @@
<avored-input
label-text="{{ __('avored::cms.page.meta_title') }}"
field-name="meta_title"
init-value="{{ $menuGroup->meta_title ?? '' }}"
init-value="{{ $page->meta_title ?? '' }}"
error-text="{{ $errors->first('meta_title') }}"
>
</avored-input>
Expand All @@ -48,16 +47,16 @@
<avored-input
label-text="{{ __('avored::cms.page.meta_description') }}"
field-name="meta_description"
init-value="{{ $menuGroup->meta_description ?? '' }}"
init-value="{{ $page->meta_description ?? '' }}"
error-text="{{ $errors->first('meta_description') }}"
>
</avored-input>
</div>

{{-- <avored-modal modal-title="{{__('avored::cms.page.widget_modal_title') }}"
<avored-modal modal-title="{{__('avored::cms.page.widget_modal_title') }}"
@close="widgetModalVisible=false"
:is-visible="widgetModalVisible">
<div class="block">
<div class="block z-30">
<avored-select
label-text="Please Select Widget"
field-name="selected_widget"
Expand All @@ -77,4 +76,4 @@ class="px-3 py-2 text-white hover:text-white bg-red-600 rounded hover:bg-red-700
</div>

</div>
</avored-modal> --}}
</avored-modal>
27 changes: 20 additions & 7 deletions resources/views/system/configuration/cards/basic.blade.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
<avored-input
label-text="{{ __('avored::system.configuration.basic.site_name') }}"
field-name="site_name"
init-value="{{ ($repository->getValueByCode('site_name')) ?? '' }}"
error-text="{{ $errors->first('site_name') }}"
>
</avored-input>
<div class="mt-3">
<avored-input
label-text="{{ __('avored::system.configuration.basic.site_name') }}"
field-name="site_name"
init-value="{{ ($repository->getValueByCode('site_name')) ?? '' }}"
error-text="{{ $errors->first('site_name') }}"
>
</avored-input>
</div>

<div class="mt-3">
<avored-select
label-text="{{ __('avored::system.configuration.basic.default_currency') }}"
field-name="default_currency"
:options="{{ $currencyOptions }}"
init-value="{{ ($repository->getValueByCode('default_currency')) ?? '' }}"
error-text="{{ $errors->first('default_currency') }}"
>
</avored-select>
</div>
15 changes: 8 additions & 7 deletions resources/views/system/configuration/cards/tax.blade.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<avored-input
label-text="{{ __('avored::system.configuration.tax.tax_percentage') }}"
field-name="tax_percentage"
init-value="{{ ($repository->getValueByCode('tax_percentage')) ?? '' }}"
error-text="{{ $errors->first('tax_percentage') }}"
>
</avored-input>
<div class="mt-3">
<avored-input
label-text="{{ __('avored::system.configuration.tax.tax_percentage') }}"
field-name="tax_percentage"
init-value="{{ ($repository->getValueByCode('tax_percentage')) ?? '' }}"
error-text="{{ $errors->first('tax_percentage') }}"
></avored-input>
</div>
4 changes: 2 additions & 2 deletions src/Database/Contracts/AddressModelInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ public function create(array $data) : Address;
public function find(int $id) : Address;

/**
* Get All Addresses from Database via User Id.
* Get All Addresses from Database via Customer Id.
* @param int $userId
* @return \Illuminate\Database\Eloquent\Collection $addresses
*/
public function getByUserId(int $userId) : Collection;
public function getByCustomerId(int $userId) : Collection;

/**
* Delete Address Resource from a database.
Expand Down
6 changes: 5 additions & 1 deletion src/Database/Contracts/CurrencyModelInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@

namespace AvoRed\Framework\Database\Contracts;

use Illuminate\Database\Eloquent\Collection;
use AvoRed\Framework\Database\Models\Currency;

interface CurrencyModelInterface extends BaseInterface
{
/**
* Get default currency from the database.
* @return \AvoRed\Framework\Database\Models\Currency $currency
*/
public function getDefault() : Currency;
}
6 changes: 3 additions & 3 deletions src/Database/Contracts/OrderModelInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
interface OrderModelInterface extends BaseInterface
{
/**
* Find Orders of a given user Id.
* Find Orders of a given customer Id.
* @param int $id
* @return \Illuminate\Database\Eloquent\Collection $userOrders
* @return \Illuminate\Database\Eloquent\Collection $customerOrders
*/
public function findByUserId(int $id) : Collection;
public function findByCustomerId(int $id) : Collection;

/**
* Get current month total orders
Expand Down
4 changes: 2 additions & 2 deletions src/Database/Repository/AddressRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ public function all() : Collection
* @param int $userId
* @return \Illuminate\Database\Eloquent\Collection $addresses
*/
public function getByUserId(int $userId) : Collection
public function getByCustomerId(int $userId) : Collection
{
return Address::whereUserId($userId)->get();
return Address::with('country')->whereCustomerId($userId)->get();
}
}
13 changes: 13 additions & 0 deletions src/Database/Repository/CurrencyRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace AvoRed\Framework\Database\Repository;

use AvoRed\Framework\Database\Contracts\ConfigurationModelInterface;
use Illuminate\Database\Eloquent\Collection;
use AvoRed\Framework\Database\Models\Currency;
use AvoRed\Framework\Database\Contracts\CurrencyModelInterface;
Expand Down Expand Up @@ -68,4 +69,16 @@ public function all() : Collection
{
return Currency::all();
}

/**
* Get default currency from the database.
* @return \AvoRed\Framework\Database\Models\Currency $currency
*/
public function getDefault() : Currency
{
$configurationRepository = app(ConfigurationModelInterface::class);
$id = $configurationRepository->getValueByCode('default_currency');

return $this->model->find($id);
}
}
4 changes: 2 additions & 2 deletions src/Database/Repository/OrderRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ public function model(): Order
* @param int $id
* @return \Illuminate\Database\Eloquent\Collection $userOrders
*/
public function findByUserId(int $id) : Collection
public function findByCustomerId(int $id) : Collection
{
return Order::whereUserId($id)->get();
return Order::whereCustomerId($id)->get();
}

/**
Expand Down
4 changes: 3 additions & 1 deletion src/Order/Listeners/OrderProductCreatedListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ public function handle(OrderProductCreated $event)
$orderProduct = $event->orderProduct;
$product = $orderProduct->product;

$product->qty -= $orderProduct->qty;
if ($product->track_stock) {
$product->qty -= $orderProduct->qty;
}
$product->save();
}
}
6 changes: 3 additions & 3 deletions src/Support/Facades/Tab.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
use Illuminate\Support\Facades\Facade;

/**
* @method \AvoRed\Framework\Tab\Manager static all()
* @method \AvoRed\Framework\Tab\Manager static put($key, $tab)
* @method static \AvoRed\Framework\Tab\Manager static get($key)
* @method static \AvoRed\Framework\Tab\Manager all()
* @method static \AvoRed\Framework\Tab\Manager put($key, $tab)
* @method static \AvoRed\Framework\Tab\Manager get($key)
*/
class Tab extends Facade
{
Expand Down
2 changes: 1 addition & 1 deletion src/Support/Middleware/AvoRedCore.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function handle($request, Closure $next)
public function setDefaultCurrency()
{
if (! Session::has('default_currency')) {
$currency = $this->currencyRepository->all()->first();
$currency = $this->currencyRepository->getDefault();
Session::put('default_currency', $currency);
}
}
Expand Down
30 changes: 15 additions & 15 deletions src/Support/Providers/TabProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,25 +163,25 @@ public function registerTabs()
->label('avored::system.tab.basic_configuration')
->view('avored::system.configuration.cards.basic');
});
Tab::put('system.configuration', function (TabItem $tab) {
$tab->key('system.configuration.user')
->label('avored::system.tab.user_configuration')
->view('avored::system.configuration.cards.user');
});
// Tab::put('system.configuration', function (TabItem $tab) {
// $tab->key('system.configuration.user')
// ->label('avored::system.tab.user_configuration')
// ->view('avored::system.configuration.cards.user');
// });
Tab::put('system.configuration', function (TabItem $tab) {
$tab->key('system.configuration.tax')
->label('avored::system.tab.tax_configuration')
->view('avored::system.configuration.cards.tax');
});
Tab::put('system.configuration', function (TabItem $tab) {
$tab->key('system.configuration.shipping')
->label('avored::system.tab.shipping_configuration')
->view('avored::system.configuration.cards.shipping');
});
Tab::put('system.configuration', function (TabItem $tab) {
$tab->key('system.configuration.payment')
->label('avored::system.tab.payment_configuration')
->view('avored::system.configuration.cards.payment');
});
// Tab::put('system.configuration', function (TabItem $tab) {
// $tab->key('system.configuration.shipping')
// ->label('avored::system.tab.shipping_configuration')
// ->view('avored::system.configuration.cards.shipping');
// });
// Tab::put('system.configuration', function (TabItem $tab) {
// $tab->key('system.configuration.payment')
// ->label('avored::system.tab.payment_configuration')
// ->view('avored::system.configuration.cards.payment');
// });
}
}
Loading

0 comments on commit 5ecf30a

Please sign in to comment.