Channel Wise Data Done
This commit is contained in:
parent
ee4c50add4
commit
75e3df73df
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddChannelToVelocityMetaDataTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('velocity_meta_data', function (Blueprint $table) {
|
||||
$table->text('channel')->after('locale');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('velocity_meta_data', function (Blueprint $table) {
|
||||
//
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -214,20 +214,26 @@ class Helper extends Review
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getVelocityMetaData($locale = null, $default = true)
|
||||
public function getVelocityMetaData($locale = null, $channel = null, $default = true)
|
||||
{
|
||||
if (! $locale) {
|
||||
$locale = request()->get('locale') ?: app()->getLocale();
|
||||
}
|
||||
|
||||
if (! $channel) {
|
||||
$channel = request()->get('channel') ?: 'default';
|
||||
}
|
||||
|
||||
try {
|
||||
$metaData = $this->velocityMetadataRepository->findOneWhere([
|
||||
'locale' => $locale
|
||||
'locale' => $locale,
|
||||
'channel' => $channel
|
||||
]);
|
||||
|
||||
if (! $metaData && $default) {
|
||||
$metaData = $this->velocityMetadataRepository->findOneWhere([
|
||||
'locale' => 'en'
|
||||
'locale' => 'en',
|
||||
'channel' => 'default'
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
@ -295,7 +301,7 @@ class Helper extends Review
|
|||
* @param \Webkul\Product\Contracts\Product $product
|
||||
* @param bool $list
|
||||
* @param array $metaInformation
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function formatProduct($product, $list = false, $metaInformation = [])
|
||||
|
|
@ -398,7 +404,7 @@ class Helper extends Review
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $productCollection;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,8 +15,16 @@ class ConfigurationController extends Controller
|
|||
*/
|
||||
protected $velocityMetaDataRepository;
|
||||
|
||||
/**
|
||||
* Locale
|
||||
*/
|
||||
protected $locale;
|
||||
|
||||
/**
|
||||
* Channel
|
||||
*/
|
||||
protected $channel;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
|
|
@ -28,10 +36,10 @@ class ConfigurationController extends Controller
|
|||
$this->_config = request('_config');
|
||||
|
||||
$this->velocityHelper = app('Webkul\Velocity\Helpers\Helper');
|
||||
|
||||
$this->velocityMetaDataRepository = $velocityMetadataRepository;
|
||||
|
||||
$this->locale = request()->get('locale') ?: app()->getLocale();
|
||||
$this->channel = request()->get('channel') ?: 'default';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -39,12 +47,12 @@ class ConfigurationController extends Controller
|
|||
*/
|
||||
public function renderMetaData()
|
||||
{
|
||||
$velocityMetaData = $this->velocityHelper->getVelocityMetaData($this->locale, false);
|
||||
$velocityMetaData = $this->velocityHelper->getVelocityMetaData($this->locale, $this->channel, false);
|
||||
|
||||
if (! $velocityMetaData) {
|
||||
$this->createMetaData($this->locale);
|
||||
$this->createMetaData($this->locale, $this->channel);
|
||||
|
||||
$velocityMetaData = $this->velocityHelper->getVelocityMetaData($this->locale);
|
||||
$velocityMetaData = $this->velocityHelper->getVelocityMetaData($this->locale, $this->channel);
|
||||
}
|
||||
|
||||
$velocityMetaData->advertisement = $this->manageAddImages(json_decode($velocityMetaData->advertisement, true) ?: []);
|
||||
|
|
@ -112,7 +120,7 @@ class ConfigurationController extends Controller
|
|||
unset($params['slides']);
|
||||
|
||||
$params['locale'] = $this->locale;
|
||||
|
||||
|
||||
// update row
|
||||
$product = $this->velocityMetaDataRepository->update($params, $id);
|
||||
|
||||
|
|
@ -125,7 +133,7 @@ class ConfigurationController extends Controller
|
|||
* @param array $data
|
||||
* @param int $index
|
||||
* @param array $advertisement
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function uploadAdvertisementImages($data, $index, $advertisement)
|
||||
|
|
@ -138,13 +146,13 @@ class ConfigurationController extends Controller
|
|||
if ($image != "") {
|
||||
$file = 'images.' . $index . '.' . $imageId;
|
||||
$dir = 'velocity/images';
|
||||
|
||||
|
||||
if (Str::contains($imageId, 'image_')) {
|
||||
if (request()->hasFile($file) && $image) {
|
||||
$filter_index = substr($imageId, 6, 1);
|
||||
if ( isset($data[$filter_index]) ) {
|
||||
$size = array_key_last($saveData[$index]);
|
||||
|
||||
|
||||
$saveImage[$size + 1] = request()->file($file)->store($dir);
|
||||
} else {
|
||||
$saveImage[substr($imageId, 6, 1)] = request()->file($file)->store($dir);
|
||||
|
|
@ -153,13 +161,13 @@ class ConfigurationController extends Controller
|
|||
} else {
|
||||
if ( isset($advertisement[$index][$imageId]) && $advertisement[$index][$imageId] && !request()->hasFile($file)) {
|
||||
$saveImage[$imageId] = $advertisement[$index][$imageId];
|
||||
|
||||
|
||||
unset($advertisement[$index][$imageId]);
|
||||
}
|
||||
|
||||
|
||||
if (request()->hasFile($file) && isset($advertisement[$index][$imageId])) {
|
||||
Storage::delete($advertisement[$index][$imageId]);
|
||||
|
||||
|
||||
$saveImage[$imageId] = request()->file($file)->store($dir);
|
||||
}
|
||||
}
|
||||
|
|
@ -192,7 +200,7 @@ class ConfigurationController extends Controller
|
|||
/**
|
||||
* @param array $data
|
||||
* @param int $index
|
||||
*
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function uploadImage($data, $index)
|
||||
|
|
@ -215,7 +223,7 @@ class ConfigurationController extends Controller
|
|||
|
||||
/**
|
||||
* @param array $addImages
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function manageAddImages($addImages)
|
||||
|
|
@ -236,14 +244,15 @@ class ConfigurationController extends Controller
|
|||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $imagePaths;
|
||||
}
|
||||
|
||||
private function createMetaData($locale)
|
||||
private function createMetaData($locale, $channel)
|
||||
{
|
||||
\DB::table('velocity_meta_data')->insert([
|
||||
'locale' => $locale,
|
||||
'channel' => $channel,
|
||||
|
||||
'home_page_content' => "<p>@include('shop::home.advertisements.advertisement-four')@include('shop::home.featured-products') @include('shop::home.product-policy') @include('shop::home.advertisements.advertisement-three') @include('shop::home.new-products') @include('shop::home.advertisements.advertisement-two')</p>",
|
||||
'footer_left_content' => __('velocity::app.admin.meta-data.footer-left-raw-content'),
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
@php
|
||||
$locale = request()->get('locale') ?: 'en';
|
||||
$channel = request()->get('channel') ?: 'default';
|
||||
@endphp
|
||||
|
||||
@section('content')
|
||||
|
|
@ -29,12 +30,13 @@
|
|||
</div>
|
||||
|
||||
<input type="hidden" name="locale" value="{{ $locale }}" />
|
||||
<input type="hidden" name="channel" value="{{ $channel }}" />
|
||||
|
||||
<div class="control-group">
|
||||
<select class="control" id="locale-switcher" onChange="window.location.href = this.value">
|
||||
@foreach (core()->getAllLocales() as $localeModel)
|
||||
|
||||
<option value="{{ route('velocity.admin.meta-data') . '?locale=' . $localeModel->code }}" {{ ($localeModel->code) == $locale ? 'selected' : '' }}>
|
||||
<option value="{{ route('velocity.admin.meta-data') . '?locale=' . $localeModel->code . '&channel=' . $channel }}" {{ ($localeModel->code) == $locale ? 'selected' : '' }}>
|
||||
{{ $localeModel->name }}
|
||||
</option>
|
||||
|
||||
|
|
@ -42,6 +44,18 @@
|
|||
</select>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<select class="control" id="channel-switcher" onChange="window.location.href = this.value">
|
||||
@foreach (core()->getAllChannels() as $ch)
|
||||
|
||||
<option value="{{ route('velocity.admin.meta-data') . '?channel=' . $ch->code . '&locale=' . $locale }}" {{ ($ch->code) == $channel ? 'selected' : '' }}>
|
||||
{{ $ch->name }}
|
||||
</option>
|
||||
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="page-action">
|
||||
<button type="submit" class="btn btn-lg btn-primary">
|
||||
{{ __('velocity::app.admin.meta-data.update-meta-data') }}
|
||||
|
|
|
|||
Loading…
Reference in New Issue