Refactor core config system
This commit is contained in:
parent
3515adeb03
commit
9d41172512
|
|
@ -1,23 +1,7 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
'flatrate' => [
|
||||
'code' => 'flatrate',
|
||||
'title' => 'Flat Rate',
|
||||
'description' => 'This is a flat rate',
|
||||
'active' => true,
|
||||
'default_rate' => '10',
|
||||
'type' => 'per_unit',
|
||||
'class' => 'Webkul\Shipping\Carriers\FlatRate',
|
||||
],
|
||||
|
||||
'free' => [
|
||||
'code' => 'free',
|
||||
'title' => 'Free Shipping',
|
||||
'description' => 'This is a free shipping',
|
||||
'active' => true,
|
||||
'class' => 'Webkul\Shipping\Carriers\Free',
|
||||
]
|
||||
|
||||
];
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
];
|
||||
|
|
@ -1,34 +1,6 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
'cashondelivery' => [
|
||||
'code' => 'cashondelivery',
|
||||
'title' => 'Cash On Delivery',
|
||||
'description' => 'Cash On Delivery',
|
||||
'class' => 'Webkul\Payment\Payment\CashOnDelivery',
|
||||
'order_status' => 'pending',
|
||||
'active' => true
|
||||
],
|
||||
|
||||
'moneytransfer' => [
|
||||
'code' => 'moneytransfer',
|
||||
'title' => 'Money Transfer',
|
||||
'description' => 'Money Transfer',
|
||||
'class' => 'Webkul\Payment\Payment\MoneyTransfer',
|
||||
'order_status' => 'pending',
|
||||
'active' => true
|
||||
],
|
||||
|
||||
'paypal_standard' => [
|
||||
'code' => 'paypal_standard',
|
||||
'title' => 'Paypal Standard',
|
||||
'description' => 'Paypal Standard',
|
||||
'class' => 'Webkul\Paypal\Payment\Standard',
|
||||
'order_status' => 'pending_payment',
|
||||
'sandbox' => true,
|
||||
'active' => true,
|
||||
'business_account' => 'test@webkul.com'
|
||||
]
|
||||
];
|
||||
|
||||
?>
|
||||
|
|
@ -483,18 +483,21 @@ class Core
|
|||
public function getConfigData($field, $channel = null, $locale = null)
|
||||
{
|
||||
if (null === $channel) {
|
||||
$channel = $this->getCurrentChannel()->code;
|
||||
$channel = request()->get('channel') ?: ($this->getCurrentChannelCode() ?: $this->getDefaultChannelCode());
|
||||
}
|
||||
|
||||
if (null === $locale) {
|
||||
$locale = app()->getLocale();
|
||||
$locale = request()->get('locale') ?: app()->getLocale();
|
||||
}
|
||||
|
||||
$coreConfigValue = $this->coreConfigRepository->findOneWhere([
|
||||
'code' => $field
|
||||
]);
|
||||
|
||||
return $coreConfigValue;
|
||||
if(!$coreConfigValue)
|
||||
return Config::get($field);
|
||||
|
||||
return $coreConfigValue->value;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
return [
|
||||
'cashondelivery' => [
|
||||
'code' => 'cashondelivery',
|
||||
'title' => 'Cash On Delivery',
|
||||
'description' => 'Cash On Delivery',
|
||||
'class' => 'Webkul\Payment\Payment\CashOnDelivery',
|
||||
'order_status' => 'pending',
|
||||
'active' => true
|
||||
],
|
||||
|
||||
'moneytransfer' => [
|
||||
'code' => 'moneytransfer',
|
||||
'title' => 'Money Transfer',
|
||||
'description' => 'Money Transfer',
|
||||
'class' => 'Webkul\Payment\Payment\MoneyTransfer',
|
||||
'order_status' => 'pending',
|
||||
'active' => true
|
||||
],
|
||||
|
||||
'paypal_standard' => [
|
||||
'code' => 'paypal_standard',
|
||||
'title' => 'Paypal Standard',
|
||||
'description' => 'Paypal Standard',
|
||||
'class' => 'Webkul\Paypal\Payment\Standard',
|
||||
'order_status' => 'pending_payment',
|
||||
'sandbox' => true,
|
||||
'active' => true,
|
||||
'business_account' => 'test@webkul.com'
|
||||
]
|
||||
];
|
||||
|
|
@ -28,6 +28,10 @@ class PaymentServiceProvider extends ServiceProvider
|
|||
public function register()
|
||||
{
|
||||
$this->registerFacades();
|
||||
|
||||
$this->mergeConfigFrom(
|
||||
dirname(__DIR__) . '/Config/paymentmethods.php', 'paymentmethods'
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Register Bouncer as a singleton.
|
||||
|
|
|
|||
|
|
@ -19,42 +19,6 @@ class FlatRate extends AbstractShipping
|
|||
*/
|
||||
protected $code = 'flatrate';
|
||||
|
||||
/**
|
||||
* Contains field details
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $fields = [
|
||||
[
|
||||
'name' => 'title',
|
||||
'title' => 'Title',
|
||||
'type' => 'text',
|
||||
'validation' => 'required',
|
||||
'channel_based' => true,
|
||||
'locale_based' => true
|
||||
], [
|
||||
'name' => 'description',
|
||||
'title' => 'Description',
|
||||
'type' => 'textarea',
|
||||
'channel_based' => true,
|
||||
'locale_based' => false
|
||||
], [
|
||||
'name' => 'active',
|
||||
'title' => 'Status',
|
||||
'type' => 'select',
|
||||
'options' => [
|
||||
[
|
||||
'title' => 'Active',
|
||||
'value' => true
|
||||
], [
|
||||
'title' => 'Inactive',
|
||||
'value' => false
|
||||
]
|
||||
],
|
||||
'validation' => 'required'
|
||||
]
|
||||
];
|
||||
|
||||
/**
|
||||
* Returns rate for flatrate
|
||||
*
|
||||
|
|
@ -77,28 +41,4 @@ class FlatRate extends AbstractShipping
|
|||
|
||||
return $object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns Configfields for flatrate
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getConfigFields()
|
||||
{
|
||||
return $this->fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns fieldDetails for flatrate
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getFieldDetails($fieldName)
|
||||
{
|
||||
foreach ($this->fields as $field) {
|
||||
if ($fieldName == $field['name']) {
|
||||
return $field;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -19,42 +19,6 @@ class Free extends AbstractShipping
|
|||
*/
|
||||
protected $code = 'free';
|
||||
|
||||
/**
|
||||
* Contains field details
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $fields = [
|
||||
[
|
||||
'name' => 'title',
|
||||
'title' => 'Title',
|
||||
'type' => 'text',
|
||||
'validation' => 'required',
|
||||
'channel_based' => false,
|
||||
'locale_based' => true
|
||||
], [
|
||||
'name' => 'description',
|
||||
'title' => 'Description',
|
||||
'type' => 'textarea',
|
||||
'channel_based' => false,
|
||||
'locale_based' => true
|
||||
], [
|
||||
'name' => 'active',
|
||||
'title' => 'Status',
|
||||
'type' => 'select',
|
||||
'options' => [
|
||||
[
|
||||
'title' => 'Active',
|
||||
'value' => true
|
||||
], [
|
||||
'title' => 'Inactive',
|
||||
'value' => false
|
||||
]
|
||||
],
|
||||
'validation' => 'required'
|
||||
]
|
||||
];
|
||||
|
||||
/**
|
||||
* Returns rate for flatrate
|
||||
*
|
||||
|
|
@ -77,28 +41,4 @@ class Free extends AbstractShipping
|
|||
|
||||
return $object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns Configfields for flatrate
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getConfigFields()
|
||||
{
|
||||
return $this->fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns fieldDetails for flatrate
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getFieldDetails($fieldName)
|
||||
{
|
||||
foreach ($this->fields as $field) {
|
||||
if ($fieldName == $field['name']) {
|
||||
return $field;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
'flatrate' => [
|
||||
'code' => 'flatrate',
|
||||
'title' => 'Flat Rate',
|
||||
'description' => 'This is a flat rate',
|
||||
'active' => true,
|
||||
'default_rate' => '10',
|
||||
'type' => 'per_unit',
|
||||
'class' => 'Webkul\Shipping\Carriers\FlatRate',
|
||||
],
|
||||
|
||||
'free' => [
|
||||
'code' => 'free',
|
||||
'title' => 'Free Shipping',
|
||||
'description' => 'This is a free shipping',
|
||||
'active' => true,
|
||||
'class' => 'Webkul\Shipping\Carriers\Free',
|
||||
]
|
||||
];
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
'carriers' => [
|
||||
'free' => [
|
||||
[
|
||||
'name' => 'title',
|
||||
'title' => 'Title',
|
||||
'type' => 'text',
|
||||
'validation' => 'required',
|
||||
'channel_based' => false,
|
||||
'locale_based' => true
|
||||
], [
|
||||
'name' => 'description',
|
||||
'title' => 'Description',
|
||||
'type' => 'textarea',
|
||||
'channel_based' => false,
|
||||
'locale_based' => true
|
||||
], [
|
||||
'name' => 'active',
|
||||
'title' => 'Status',
|
||||
'type' => 'select',
|
||||
'options' => [
|
||||
[
|
||||
'title' => 'Active',
|
||||
'value' => true
|
||||
], [
|
||||
'title' => 'Inactive',
|
||||
'value' => false
|
||||
]
|
||||
],
|
||||
'validation' => 'required'
|
||||
]
|
||||
],
|
||||
'flatrate' => [
|
||||
[
|
||||
'name' => 'title',
|
||||
'title' => 'Title',
|
||||
'type' => 'text',
|
||||
'validation' => 'required',
|
||||
'channel_based' => true,
|
||||
'locale_based' => true
|
||||
], [
|
||||
'name' => 'description',
|
||||
'title' => 'Description',
|
||||
'type' => 'textarea',
|
||||
'channel_based' => true,
|
||||
'locale_based' => false
|
||||
], [
|
||||
'name' => 'active',
|
||||
'title' => 'Status',
|
||||
'type' => 'select',
|
||||
'options' => [
|
||||
[
|
||||
'title' => 'Active',
|
||||
'value' => true
|
||||
], [
|
||||
'title' => 'Inactive',
|
||||
'value' => false
|
||||
]
|
||||
],
|
||||
'validation' => 'required'
|
||||
]
|
||||
]
|
||||
]
|
||||
];
|
||||
|
|
@ -29,7 +29,10 @@ class ShippingServiceProvider extends ServiceProvider
|
|||
public function register()
|
||||
{
|
||||
$this->registerFacades();
|
||||
|
||||
$this->registerConfig();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register Bouncer as a singleton.
|
||||
*
|
||||
|
|
@ -44,4 +47,20 @@ class ShippingServiceProvider extends ServiceProvider
|
|||
return new Shipping();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Register package config.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function registerConfig()
|
||||
{
|
||||
$this->mergeConfigFrom(
|
||||
dirname(__DIR__) . '/Config/carriers.php', 'carriers'
|
||||
);
|
||||
|
||||
$this->mergeConfigFrom(
|
||||
dirname(__DIR__) . '/Config/fields.php', 'core'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -1,4 +1,4 @@
|
|||
{
|
||||
"/js/ui.js": "/js/ui.js",
|
||||
"/css/ui.css": "/css/ui.css"
|
||||
}
|
||||
"/js/ui.js": "/js/ui.js?id=1fdce572fb02cd8c7dad",
|
||||
"/css/ui.css": "/css/ui.css?id=e78eaaed7f89740f42d9"
|
||||
}
|
||||
Loading…
Reference in New Issue