Method Added For Fetching Channel Name

This commit is contained in:
devansh bawari 2021-02-11 17:34:12 +05:30
parent f8f432058e
commit df6e890dfe
14 changed files with 31 additions and 13 deletions

View File

@ -14,7 +14,7 @@
<select class="control" name="channels[]" v-validate="'required'" data-vv-as="&quot;{{ __('admin::app.catalog.products.channel') }}&quot;" multiple>
@foreach (app('Webkul\Core\Repositories\ChannelRepository')->all() as $channel)
<option value="{{ $channel->id }}" {{ in_array($channel->code, $productChannels) ? 'selected' : ''}}>
{{ $channel->name ?? $channel->translate(app()->getLocale())->name ?? $channel->translate(config('app.fallback_locale'))->name }}
{{ core()->getChannelName($channel) }}
</option>
@endforeach
</select>

View File

@ -37,7 +37,7 @@
<option
value="{{ $channelModel->code }}" {{ ($channelModel->code) == $channel ? 'selected' : '' }}>
{{ $channelModel->name ?? $channelModel->translate($locale)->name ?? $channelModel->translate(config('app.fallback_locale'))->name }}
{{ core()->getChannelName($channelModel) }}
</option>
@endforeach

View File

@ -48,7 +48,7 @@
<select type="text" class="control" name="channels[]" v-validate="'required'" value="{{ old('channel[]') }}" data-vv-as="&quot;{{ __('admin::app.cms.pages.channel') }}&quot;" multiple="multiple">
@foreach($channels->all() as $channel)
<option value="{{ $channel->id }}">{{ $channel->name ?? $channel->translate(app()->getLocale())->name ?? $channel->translate(config('app.fallback_locale'))->name }}</option>
<option value="{{ $channel->id }}">{{ core()->getChannelName($channel) }}</option>
@endforeach
</select>

View File

@ -66,7 +66,7 @@
<select type="text" class="control" name="channels[]" v-validate="'required'" value="{{ old('channel[]') }}" data-vv-as="&quot;{{ __('admin::app.cms.pages.channel') }}&quot;" multiple="multiple">
@foreach(app('Webkul\Core\Repositories\ChannelRepository')->all() as $channel)
<option value="{{ $channel->id }}" {{ in_array($channel->id, $selectedOptionIds) ? 'selected' : '' }}>
{{ $channel->name ?? $channel->translate(app()->getLocale())->name ?? $channel->translate(config('app.fallback_locale'))->name }}
{{ core()->getChannelName($channel) }}
</option>
@endforeach
</select>

View File

@ -23,7 +23,7 @@
@foreach (core()->getAllChannels() as $channelModel)
<option value="{{ $channelModel->code }}" {{ ($channelModel->code) == $channel ? 'selected' : '' }}>
{{ $channelModel->name ?? $channelModel->translate($locale)->name ?? $channelModel->translate(config('app.fallback_locale'))->name }}
{{ core()->getChannelName($channel) }}
</option>
@endforeach

View File

@ -93,7 +93,7 @@
<select v-validate="'required'" class="control" id="channel_id" name="channel_id" data-vv-as="&quot;{{ __('admin::app.marketing.campaigns.channel') }}&quot;">
@foreach (app('Webkul\Core\Repositories\ChannelRepository')->all() as $channel)
<option value="{{ $channel->id }}" {{ old('channel_id') == $channel->id ? 'selected' : '' }}>
{{ $channel->name ?? $channel->translate(app()->getLocale())->name ?? $channel->translate(config('app.fallback_locale'))->name }}
{{ core()->getChannelName($channel) }}
</option>
@endforeach
</select>

View File

@ -97,7 +97,7 @@
<select v-validate="'required'" class="control" id="channel_id" name="channel_id" data-vv-as="&quot;{{ __('admin::app.marketing.campaigns.channel') }}&quot;">
@foreach (app('Webkul\Core\Repositories\ChannelRepository')->all() as $channel)
<option value="{{ $channel->id }}" {{ $selectedOption == $channel->id ? 'selected' : '' }}>
{{ $channel->name ?? $channel->translate(app()->getLocale())->name ?? $channel->translate(config('app.fallback_locale'))->name }}
{{ core()->getChannelName($channel) }}
</option>
@endforeach
</select>

View File

@ -71,7 +71,7 @@
@foreach(core()->getAllChannels() as $channel)
<option value="{{ $channel->id }}" {{ old('channels') && in_array($channel->id, old('channels')) ? 'selected' : '' }}>
{{ $channel->name ?? $channel->translate(app()->getLocale())->name ?? $channel->translate(config('app.fallback_locale'))->name }}
{{ core()->getChannelName($channel) }}
</option>
@endforeach

View File

@ -78,7 +78,7 @@
@foreach(core()->getAllChannels() as $channel)
<option value="{{ $channel->id }}" {{ in_array($channel->id, $selectedOptionIds) ? 'selected' : '' }}>
{{ $channel->name ?? $channel->translate(app()->getLocale())->name ?? $channel->translate(config('app.fallback_locale'))->name }}
{{ core()->getChannelName($channel) }}
</option>
@endforeach

View File

@ -71,7 +71,7 @@
@foreach(core()->getAllChannels() as $channel)
<option value="{{ $channel->id }}" {{ old('channels') && in_array($channel->id, old('channels')) ? 'selected' : '' }}>
{{ $channel->name ?? $channel->translate(app()->getLocale())->name ?? $channel->translate(config('app.fallback_locale'))->name }}
{{ core()->getChannelName($channel) }}
</option>
@endforeach

View File

@ -73,7 +73,7 @@
@foreach(core()->getAllChannels() as $channel)
<option value="{{ $channel->id }}" {{ in_array($channel->id, $selectedOptionIds) ? 'selected' : '' }}>
{{ $channel->name ?? $channel->translate(app()->getLocale())->name ?? $channel->translate(config('app.fallback_locale'))->name }}
{{ core()->getChannelName($channel) }}
</option>
@endforeach

View File

@ -221,6 +221,24 @@ class Core
return ($channel = $this->getDefaultChannel()) ? $channelCode = $channel->code : '';
}
/**
* Returns the channel name.
*
* @return string
*/
public function getChannelName($channel): string
{
static $channelName;
if ($channelName) {
return $channelName;
}
return $channelName = $channel->name
?? $channel->translate(app()->getLocale())->name
?? $channel->translate(config('app.fallback_locale'))->name;
}
/**
* Returns all locales
*

View File

@ -44,7 +44,7 @@
<option
value="{{ $channelModel->code }}"
{{ (isset($channel) && ($channelModel->code) == $channel) ? 'selected' : '' }}>
{{ $channelModel->name ?? $channelModel->translate($locale)->name ?? $channelModel->translate(config('app.fallback_locale'))->name }}
{{ core()->getChannelName($channelModel) }}
</option>
@endforeach
</select>

View File

@ -44,7 +44,7 @@
<option
value="{{ $channelModel->code }}" {{ ($channelModel->code) == $channel ? 'selected' : '' }}>
{{ $channelModel->name ?? $channelModel->translate($locale)->name ?? $channelModel->translate(config('app.fallback_locale'))->name }}
{{ core()->getChannelName($channel) }}
</option>
@endforeach