Improved core package code style

This commit is contained in:
Jitendra Singh 2020-02-19 17:56:12 +05:30
parent 687df3dbdd
commit 5fb33d4fc9
18 changed files with 147 additions and 111 deletions

View File

@ -111,8 +111,9 @@ class Core
{
static $channels;
if ($channels)
if ($channels) {
return $channels;
}
return $channels = $this->channelRepository->all();
}
@ -126,8 +127,9 @@ class Core
{
static $channel;
if ($channel)
if ($channel) {
return $channel;
}
$channel = $this->channelRepository->findWhereIn('hostname', [
request()->getHttpHost(),
@ -135,8 +137,9 @@ class Core
'https://' . request()->getHttpHost(),
])->first();
if (! $channel)
if (! $channel) {
$channel = $this->channelRepository->first();
}
return $channel;
}
@ -150,8 +153,9 @@ class Core
{
static $channelCode;
if ($channelCode)
if ($channelCode) {
return $channelCode;
}
return ($channel = $this->getCurrentChannel()) ? $channelCode = $channel->code : '';
}
@ -203,8 +207,9 @@ class Core
{
static $locales;
if ($locales)
if ($locales) {
return $locales;
}
return $locales = $this->localeRepository->all();
}
@ -240,8 +245,9 @@ class Core
{
static $currencies;
if ($currencies)
if ($currencies) {
return $currencies;
}
return $currencies = $this->currencyRepository->all();
}
@ -255,13 +261,15 @@ class Core
{
static $currency;
if ($currency)
if ($currency) {
return $currency;
}
$baseCurrency = $this->currencyRepository->findOneByField('code', config('app.currency'));
if (! $baseCurrency)
if (! $baseCurrency) {
$baseCurrency = $this->currencyRepository->first();
}
return $currency = $baseCurrency;
}
@ -275,8 +283,9 @@ class Core
{
static $currencyCode;
if ($currencyCode)
if ($currencyCode) {
return $currencyCode;
}
return ($currency = $this->getBaseCurrency()) ? $currencyCode = $currency->code : '';
}
@ -290,8 +299,9 @@ class Core
{
static $currency;
if ($currency)
if ($currency) {
return $currency;
}
$currenctChannel = $this->getCurrentChannel();
@ -307,8 +317,9 @@ class Core
{
static $currencyCode;
if ($currencyCode)
if ($currencyCode) {
return $currencyCode;
}
return ($currency = $this->getChannelBaseCurrency()) ? $currencyCode = $currency->code : '';
}
@ -322,12 +333,14 @@ class Core
{
static $currency;
if ($currency)
if ($currency) {
return $currency;
}
if ($currencyCode = session()->get('currency')) {
if ($currency = $this->currencyRepository->findOneByField('code', $currencyCode))
if ($currency = $this->currencyRepository->findOneByField('code', $currencyCode)) {
return $currency;
}
}
return $currency = $this->getChannelBaseCurrency();
@ -342,8 +355,9 @@ class Core
{
static $currencyCode;
if ($currencyCode)
if ($currencyCode) {
return $currencyCode;
}
return ($currency = $this->getCurrentCurrency()) ? $currencyCode = $currency->code : '';
}
@ -358,27 +372,31 @@ class Core
*/
public function convertPrice($amount, $targetCurrencyCode = null)
{
if (! isset($this->lastCurrencyCode))
if (! isset($this->lastCurrencyCode)) {
$this->lastCurrencyCode = $this->getBaseCurrency()->code;
}
$targetCurrency = ! $targetCurrencyCode
? $this->getCurrentCurrency()
: $this->currencyRepository->findOneByField('code', $targetCurrencyCode);
if (! $targetCurrency)
if (! $targetCurrency) {
return $amount;
}
$exchangeRate = $this->exchangeRateRepository->findOneWhere([
'target_currency' => $targetCurrency->id,
]);
if (null === $exchangeRate || ! $exchangeRate->rate)
if (null === $exchangeRate || ! $exchangeRate->rate) {
return $amount;
}
$result = (float)$amount * (float)($this->lastCurrencyCode == $targetCurrency->code ? 1.0 : $exchangeRate->rate);
if ($this->lastCurrencyCode != $targetCurrency->code)
if ($this->lastCurrencyCode != $targetCurrency->code) {
$this->lastCurrencyCode = $targetCurrency->code;
}
return $result;
}
@ -397,15 +415,17 @@ class Core
? $this->getCurrentCurrency()
: $this->currencyRepository->findOneByField('code', $targetCurrencyCode);
if (! $targetCurrency)
if (! $targetCurrency) {
return $amount;
}
$exchangeRate = $this->exchangeRateRepository->findOneWhere([
'target_currency' => $targetCurrency->id,
]);
if (null === $exchangeRate || ! $exchangeRate->rate)
if (null === $exchangeRate || ! $exchangeRate->rate) {
return $amount;
}
return (float)$amount / $exchangeRate->rate;
}
@ -419,8 +439,9 @@ class Core
*/
public function currency($amount = 0)
{
if (is_null($amount))
if (is_null($amount)) {
$amount = 0;
}
return $this->formatPrice($this->convertPrice($amount), $this->getCurrentCurrency()->code);
}
@ -448,8 +469,9 @@ class Core
*/
public function formatPrice($price, $currencyCode)
{
if (is_null($price))
if (is_null($price)) {
$price = 0;
}
$formater = new \NumberFormatter(app()->getLocale(), \NumberFormatter::CURRENCY);
@ -497,8 +519,9 @@ class Core
*/
public function formatBasePrice($price)
{
if (is_null($price))
if (is_null($price)) {
$price = 0;
}
$formater = new \NumberFormatter(app()->getLocale(), \NumberFormatter::CURRENCY);
@ -540,7 +563,7 @@ class Core
if (! $this->is_empty_date($dateFrom) && $channelTimeStamp < $fromTimeStamp) {
$result = false;
} elseif (! $this->is_empty_date($dateTo) && $channelTimeStamp > $toTimeStamp) {
} else if (! $this->is_empty_date($dateTo) && $channelTimeStamp > $toTimeStamp) {
$result = false;
} else {
$result = true;
@ -964,8 +987,9 @@ class Core
{
static $instance = [];
if (array_key_exists($className, $instance))
if (array_key_exists($className, $instance)) {
return $instance[$className];
}
return $instance[$className] = app($className);
}

View File

@ -5,10 +5,9 @@ use Webkul\Core\Models\Locale;
/** @var \Illuminate\Database\Eloquent\Factory $factory */
$factory->define(Locale::class, function (Faker $faker, array $attributes) {
return [
'code' => $faker->languageCode,
'name' => $faker->country,
'code' => $faker->languageCode,
'name' => $faker->country,
'direction' => 'ltr',
];
});

View File

@ -12,31 +12,31 @@ class ChannelTableSeeder extends Seeder
DB::table('channels')->delete();
DB::table('channels')->insert([
'id' => 1,
'code' => 'default',
'name' => 'Default',
'root_category_id' => 1,
'id' => 1,
'code' => 'default',
'name' => 'Default',
'root_category_id' => 1,
'home_page_content' => '<p>@include("shop::home.slider") @include("shop::home.featured-products") @include("shop::home.new-products")</p><div class="banner-container"><div class="left-banner"><img src="https://s3-ap-southeast-1.amazonaws.com/cdn.uvdesk.com/website/1/201902045c581f9494b8a1.png" /></div><div class="right-banner"><img src="https://s3-ap-southeast-1.amazonaws.com/cdn.uvdesk.com/website/1/201902045c581fb045cf02.png" /> <img src="https://s3-ap-southeast-1.amazonaws.com/cdn.uvdesk.com/website/1/201902045c581fc352d803.png" /></div></div>',
'footer_content' => '<div class="list-container"><span class="list-heading">Quick Links</span><ul class="list-group"><li><a href="@php echo route(\'shop.cms.page\', \'about-us\') @endphp">About Us</a></li><li><a href="@php echo route(\'shop.cms.page\', \'return-policy\') @endphp">Return Policy</a></li><li><a href="@php echo route(\'shop.cms.page\', \'refund-policy\') @endphp">Refund Policy</a></li><li><a href="@php echo route(\'shop.cms.page\', \'terms-conditions\') @endphp">Terms and conditions</a></li><li><a href="@php echo route(\'shop.cms.page\', \'terms-of-use\') @endphp">Terms of Use</a></li><li><a href="@php echo route(\'shop.cms.page\', \'contact-us\') @endphp">Contact Us</a></li></ul></div><div class="list-container"><span class="list-heading">Connect With Us</span><ul class="list-group"><li><a href="#"><span class="icon icon-facebook"></span>Facebook </a></li><li><a href="#"><span class="icon icon-twitter"></span> Twitter </a></li><li><a href="#"><span class="icon icon-instagram"></span> Instagram </a></li><li><a href="#"> <span class="icon icon-google-plus"></span>Google+ </a></li><li><a href="#"> <span class="icon icon-linkedin"></span>LinkedIn </a></li></ul></div>',
'name' => 'Default',
'footer_content' => '<div class="list-container"><span class="list-heading">Quick Links</span><ul class="list-group"><li><a href="@php echo route(\'shop.cms.page\', \'about-us\') @endphp">About Us</a></li><li><a href="@php echo route(\'shop.cms.page\', \'return-policy\') @endphp">Return Policy</a></li><li><a href="@php echo route(\'shop.cms.page\', \'refund-policy\') @endphp">Refund Policy</a></li><li><a href="@php echo route(\'shop.cms.page\', \'terms-conditions\') @endphp">Terms and conditions</a></li><li><a href="@php echo route(\'shop.cms.page\', \'terms-of-use\') @endphp">Terms of Use</a></li><li><a href="@php echo route(\'shop.cms.page\', \'contact-us\') @endphp">Contact Us</a></li></ul></div><div class="list-container"><span class="list-heading">Connect With Us</span><ul class="list-group"><li><a href="#"><span class="icon icon-facebook"></span>Facebook </a></li><li><a href="#"><span class="icon icon-twitter"></span> Twitter </a></li><li><a href="#"><span class="icon icon-instagram"></span> Instagram </a></li><li><a href="#"> <span class="icon icon-google-plus"></span>Google+ </a></li><li><a href="#"> <span class="icon icon-linkedin"></span>LinkedIn </a></li></ul></div>',
'name' => 'Default',
'default_locale_id' => 1,
'base_currency_id' => 1,
'home_seo' => '{"meta_title": "Demo store", "meta_keywords": "Demo store meta keyword", "meta_description": "Demo store meta description"}',
'base_currency_id' => 1,
'home_seo' => '{"meta_title": "Demo store", "meta_keywords": "Demo store meta keyword", "meta_description": "Demo store meta description"}'
]);
DB::table('channel_currencies')->insert([
'channel_id' => 1,
'currency_id' => 1,
'channel_id' => 1,
'currency_id' => 1
]);
DB::table('channel_locales')->insert([
'channel_id' => 1,
'locale_id' => 1,
'locale_id' => 1
]);
DB::table('channel_inventory_sources')->insert([
'channel_id' => 1,
'inventory_source_id' => 1,
'channel_id' => 1,
'inventory_source_id' => 1
]);
}
}

View File

@ -25,6 +25,7 @@ class CountryStateTranslationSeeder extends Seeder
data_fill($stateTranslations, '*.locale', $code);
DB::table('country_translations')->insert($countryTranslations);
DB::table('country_state_translations')->insert($stateTranslations);
}

View File

@ -14,13 +14,13 @@ class CurrencyTableSeeder extends Seeder
DB::table('currencies')->delete();
DB::table('currencies')->insert([
'id' => 1,
'code' => 'USD',
'name' => 'US Dollar'
'id' => 1,
'code' => 'USD',
'name' => 'US Dollar'
], [
'id' => 2,
'code' => 'EUR',
'name' => 'Euro',
'id' => 2,
'code' => 'EUR',
'name' => 'Euro',
'symbol' => '€'
]);
}

View File

@ -14,11 +14,11 @@ class LocalesTableSeeder extends Seeder
DB::table('locales')->delete();
DB::table('locales')->insert([
'id' => 1,
'id' => 1,
'code' => 'en',
'name' => 'English',
], [
'id' => 2,
'id' => 2,
'code' => 'fr',
'name' => 'French',
]);

View File

@ -25,8 +25,9 @@ class TranslatableModel extends Model
{
$chunks = explode('-', $key);
if (count($chunks) > 1) {
if (Locale::where('code', '=', end($chunks))->first())
if (Locale::where('code', '=', end($chunks))->first()) {
return true;
}
} else if (Locale::where('code', '=', $key)->first()) {
return true;
}

View File

@ -26,7 +26,7 @@ class FixerExchange extends ExchangeRate
{
$this->apiKey = config('services.exchange-api')['fixer']['key'];
$this->apiEndPoint = 'http://data.fixer.io/api/latest?access_key='.$this->apiKey;
$this->apiEndPoint = 'http://data.fixer.io/api/latest?access_key=' . $this->apiKey;
}
public function fetchRates()
@ -39,10 +39,9 @@ class FixerExchange extends ExchangeRate
$client = new \GuzzleHttp\Client();
if (config('services.exchange-api')['fixer']['paid_account']) {
$result = $client->request('GET', 'http://data.fixer.io/api/'.date('Y-m-d').'?access_key='.$this->apiKey.'&base='.core()->getBaseCurrency()->code.'&symbols=INR');
$result = $client->request('GET', 'http://data.fixer.io/api/' . date('Y-m-d').'?access_key=' . $this->apiKey.'&base=' . core()->getBaseCurrency()->code . '&symbols=INR');
} else {
$result = $client->request('GET', 'http://data.fixer.io/api/'.date('Y-m-d').'?access_key='.$this->apiKey.'&symbols=USD');
$result = $client->request('GET', 'http://data.fixer.io/api/' . date('Y-m-d') . '?access_key=' . $this->apiKey . '&symbols=USD');
}
$result = json_decode($result->getBody()->getContents());

View File

@ -58,9 +58,10 @@ class Laravel5Helper extends Laravel5
'brand' => 'text_value',
'guest_checkout' => 'boolean_value',
];
if (!array_key_exists($attribute, $attributes)) {
if (! array_key_exists($attribute, $attributes)) {
return null;
}
return $attributes[$attribute];
}
@ -80,10 +81,12 @@ class Laravel5Helper extends Laravel5
switch ($productType) {
case self::DOWNLOADABLE_PRODUCT:
$product = $I->haveDownloadableProduct($configs, $productStates);
break;
case self::VIRTUAL_PRODUCT:
$product = $I->haveVirtualProduct($configs, $productStates);
break;
case self::SIMPLE_PRODUCT:
@ -107,7 +110,8 @@ class Laravel5Helper extends Laravel5
private function haveSimpleProduct(array $configs = [], array $productStates = []): Product
{
$I = $this;
if (!in_array('simple', $productStates)) {
if (! in_array('simple', $productStates)) {
$productStates = array_merge($productStates, ['simple']);
}
@ -130,7 +134,8 @@ class Laravel5Helper extends Laravel5
private function haveVirtualProduct(array $configs = [], array $productStates = []): Product
{
$I = $this;
if (!in_array('virtual', $productStates)) {
if (! in_array('virtual', $productStates)) {
$productStates = array_merge($productStates, ['virtual']);
}
@ -153,7 +158,8 @@ class Laravel5Helper extends Laravel5
private function haveDownloadableProduct(array $configs = [], array $productStates = []): Product
{
$I = $this;
if (!in_array('downloadable', $productStates)) {
if (! in_array('downloadable', $productStates)) {
$productStates = array_merge($productStates, ['downloadable']);
}
@ -185,6 +191,7 @@ class Laravel5Helper extends Laravel5
private function createInventory(int $productId, array $inventoryConfig = []): void
{
$I = $this;
$I->have(ProductInventory::class, array_merge($inventoryConfig, [
'product_id' => $productId,
'inventory_source_id' => 1,
@ -197,6 +204,7 @@ class Laravel5Helper extends Laravel5
private function createDownloadableLink(int $productId): void
{
$I = $this;
$link = $I->have(ProductDownloadableLink::class, [
'product_id' => $productId,
]);
@ -232,16 +240,20 @@ class Laravel5Helper extends Laravel5
'meta_description',
'weight',
];
foreach ($productAttributeValues as $attribute) {
$data = ['product_id' => $productId];
if (array_key_exists($attribute, $attributeValues)) {
$fieldName = self::getAttributeFieldName($attribute);
if (!array_key_exists($fieldName, $data)) {
$data[$fieldName] = $attributeValues[$attribute];
} else {
$data = [$fieldName => $attributeValues[$attribute]];
}
}
$I->have(ProductAttributeValue::class, $data, $attribute);
}
}

View File

@ -68,19 +68,19 @@ class ChannelController extends Controller
public function store()
{
$this->validate(request(), [
'code' => ['required', 'unique:channels,code', new \Webkul\Core\Contracts\Validations\Code],
'name' => 'required',
'locales' => 'required|array|min:1',
'code' => ['required', 'unique:channels,code', new \Webkul\Core\Contracts\Validations\Code],
'name' => 'required',
'locales' => 'required|array|min:1',
'default_locale_id' => 'required|in_array:locales.*',
'currencies' => 'required|array|min:1',
'base_currency_id' => 'required|in_array:currencies.*',
'root_category_id' => 'required',
'logo.*' => 'mimes:jpeg,jpg,bmp,png',
'favicon.*' => 'mimes:jpeg,jpg,bmp,png',
'seo_title' => 'required|string',
'seo_description' => 'required|string',
'seo_keywords' => 'required|string',
'hostname' => 'unique:channels,hostname',
'currencies' => 'required|array|min:1',
'base_currency_id' => 'required|in_array:currencies.*',
'root_category_id' => 'required',
'logo.*' => 'mimes:jpeg,jpg,bmp,png',
'favicon.*' => 'mimes:jpeg,jpg,bmp,png',
'seo_title' => 'required|string',
'seo_description' => 'required|string',
'seo_keywords' => 'required|string',
'hostname' => 'unique:channels,hostname',
]);
$data = request()->all();
@ -130,17 +130,17 @@ class ChannelController extends Controller
public function update($id)
{
$this->validate(request(), [
'code' => ['required', 'unique:channels,code,' . $id, new \Webkul\Core\Contracts\Validations\Code],
'name' => 'required',
'locales' => 'required|array|min:1',
'code' => ['required', 'unique:channels,code,' . $id, new \Webkul\Core\Contracts\Validations\Code],
'name' => 'required',
'locales' => 'required|array|min:1',
'inventory_sources' => 'required|array|min:1',
'default_locale_id' => 'required|in_array:locales.*',
'currencies' => 'required|array|min:1',
'base_currency_id' => 'required|in_array:currencies.*',
'root_category_id' => 'required',
'logo.*' => 'mimes:jpeg,jpg,bmp,png',
'favicon.*' => 'mimes:jpeg,jpg,bmp,png',
'hostname' => 'unique:channels,hostname,' . $id,
'currencies' => 'required|array|min:1',
'base_currency_id' => 'required|in_array:currencies.*',
'root_category_id' => 'required',
'logo.*' => 'mimes:jpeg,jpg,bmp,png',
'favicon.*' => 'mimes:jpeg,jpg,bmp,png',
'hostname' => 'unique:channels,hostname,' . $id,
]);
$data = request()->all();

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);
@ -153,8 +153,8 @@ class ExchangeRateController extends Controller
if (! array_key_exists('class', $exchangeService)) {
return response()->json([
'success' => false,
'rates' => null,
'error' => trans('admin::app.exchange-rate.exchange-class-not-found', [
'rates' => null,
'error' => trans('admin::app.exchange-rate.exchange-class-not-found', [
'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')
'rates' => null,
'error' => trans('admin::app.exchange-rate.invalid-config')
], 400);
}
}
@ -201,6 +201,7 @@ class ExchangeRateController extends Controller
return response()->json(['message' => true], 200);
} catch (\Exception $e) {
report($e);
session()->flash('error', trans('admin::app.response.delete-error', ['name' => 'Exchange rate']));
}
}

View File

@ -68,8 +68,8 @@ class LocaleController extends Controller
public function store()
{
$this->validate(request(), [
'code' => ['required', 'unique:locales,code', new \Webkul\Core\Contracts\Validations\Code],
'name' => 'required',
'code' => ['required', 'unique:locales,code', new \Webkul\Core\Contracts\Validations\Code],
'name' => 'required',
'direction' => 'in:ltr,rtl'
]);
@ -106,8 +106,8 @@ class LocaleController extends Controller
public function update($id)
{
$this->validate(request(), [
'code' => ['required', 'unique:locales,code,' . $id, new \Webkul\Core\Contracts\Validations\Code],
'name' => 'required',
'code' => ['required', 'unique:locales,code,' . $id, new \Webkul\Core\Contracts\Validations\Code],
'name' => 'required',
'direction' => 'in:ltr,rtl'
]);

View File

@ -74,9 +74,9 @@ class SliderController extends Controller
public function store()
{
$this->validate(request(), [
'title' => 'string|required',
'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());
@ -109,9 +109,9 @@ class SliderController extends Controller
public function update($id)
{
$this->validate(request(), [
'title' => 'string|required',
'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)) {

View File

@ -80,7 +80,6 @@ class SubscriptionController extends Controller
if ($result)
session()->flash('success', trans('admin::app.customers.subscribers.update-success'));
// session()->flash('success', 'admin::app.customers.subscribers.delete-success');
else
session()->flash('error', trans('admin::app.customers.subscribers.update-failed'));

View File

@ -44,9 +44,6 @@ class Channel extends Model implements ChannelContract
return $this->belongsToMany(InventorySourceProxy::modelClass(), 'channel_inventory_sources');
}
// protected $with = ['base_currency'];
/**
* Get the base currency
*/
@ -68,8 +65,9 @@ class Channel extends Model implements ChannelContract
*/
public function logo_url()
{
if (! $this->logo)
if (! $this->logo) {
return;
}
return Storage::url($this->logo);
}
@ -87,8 +85,9 @@ class Channel extends Model implements ChannelContract
*/
public function favicon_url()
{
if (! $this->favicon)
if (! $this->favicon) {
return;
}
return Storage::url($this->favicon);
}

View File

@ -24,8 +24,9 @@ class Slider extends Model implements SliderContract
*/
public function image_url()
{
if (! $this->path)
if (! $this->path) {
return;
}
return Storage::url($this->path);
}

View File

@ -85,9 +85,9 @@ class CoreConfigRepository extends Repository
if (! count($coreConfigValue)) {
$this->model->create([
'code' => $fieldName,
'value' => $value,
'locale_code' => $localeBased ? $locale : null,
'code' => $fieldName,
'value' => $value,
'locale_code' => $localeBased ? $locale : null,
'channel_code' => $channelBased ? $channel : null
]);
} else {
@ -98,9 +98,9 @@ class CoreConfigRepository extends Repository
$this->model->destroy($coreConfig['id']);
} else {
$coreConfig->update([
'code' => $fieldName,
'value' => $value,
'locale_code' => $localeBased ? $locale : null,
'code' => $fieldName,
'value' => $value,
'locale_code' => $localeBased ? $locale : null,
'channel_code' => $channelBased ? $channel : null
]);
}

View File

@ -62,15 +62,15 @@ class SliderRepository extends Repository
$dir = 'slider_images/' . $channelName;
$uploaded = false;
$image = false;
$uploaded = $image = false;
if (isset($data['image'])) {
$image = $first = Arr::first($data['image'], function ($value, $key) {
if ($value)
if ($value) {
return $value;
else
} else {
return false;
}
});
}