Merge pull request #61 from bagisto/jitendra
Get current channel code updated
This commit is contained in:
commit
22713906d2
|
|
@ -31,7 +31,7 @@ Route::group(['middleware' => ['web']], function () {
|
|||
|
||||
|
||||
// Admin Routes
|
||||
Route::group(['middleware' => ['admin', 'locale']], function () {
|
||||
Route::group(['middleware' => ['admin']], function () {
|
||||
Route::get('/logout', 'Webkul\User\Http\Controllers\SessionController@destroy')->defaults('_config', [
|
||||
'redirect' => 'admin.session.create'
|
||||
])->name('admin.session.destroy');
|
||||
|
|
|
|||
|
|
@ -382,6 +382,7 @@ return [
|
|||
'code' => 'Code',
|
||||
'name' => 'Name',
|
||||
'description' => 'Description',
|
||||
'hostname' => 'Hostname',
|
||||
'currencies-and-locales' => 'Currencies and Locales',
|
||||
'locales' => 'Locales',
|
||||
'default-locale' => 'Default Locale',
|
||||
|
|
|
|||
|
|
@ -45,6 +45,11 @@
|
|||
<span class="control-error" v-if="errors.has('description')">@{{ errors.first('description') }}</span>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<label for="hostname">{{ __('admin::app.settings.channels.hostname') }}</label>
|
||||
<input class="control" id="hostname" name="hostname" value="{{ old('hostname') }}" placeholder="https://www.example.com"/>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</accordian>
|
||||
|
||||
|
|
|
|||
|
|
@ -47,6 +47,11 @@
|
|||
<span class="control-error" v-if="errors.has('description')">@{{ errors.first('description') }}</span>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<label for="hostname">{{ __('admin::app.settings.channels.hostname') }}</label>
|
||||
<input type="text" class="control" id="hostname" name="hostname" value="{{ $channel->hostname }}" placeholder="https://www.example.com"/>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</accordian>
|
||||
|
||||
|
|
|
|||
|
|
@ -93,7 +93,8 @@ class Core
|
|||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getAllChannels() {
|
||||
public function getAllChannels()
|
||||
{
|
||||
static $channels;
|
||||
|
||||
if($channels)
|
||||
|
|
@ -107,13 +108,23 @@ class Core
|
|||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getCurrentChannel() {
|
||||
public function getCurrentChannel()
|
||||
{
|
||||
static $channel;
|
||||
|
||||
if($channel)
|
||||
return $channel;
|
||||
|
||||
return $channel = $this->channelRepository->first();
|
||||
$channel = $this->channelRepository->findWhereIn('hostname', [
|
||||
request()->getHttpHost(),
|
||||
'http://' . request()->getHttpHost(),
|
||||
'https://' . request()->getHttpHost()
|
||||
])->first();
|
||||
|
||||
if(!$channel)
|
||||
$channel = $this->channelRepository->first();
|
||||
|
||||
return $channel;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -121,7 +132,8 @@ class Core
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCurrentChannelCode() {
|
||||
public function getCurrentChannelCode()
|
||||
{
|
||||
static $channelCode;
|
||||
|
||||
if($channelCode)
|
||||
|
|
@ -135,7 +147,8 @@ class Core
|
|||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getDefaultChannel() {
|
||||
public function getDefaultChannel()
|
||||
{
|
||||
static $channel;
|
||||
|
||||
if($channel)
|
||||
|
|
@ -149,7 +162,8 @@ class Core
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDefaultChannelCode() {
|
||||
public function getDefaultChannelCode()
|
||||
{
|
||||
static $channelCode;
|
||||
|
||||
if($channelCode)
|
||||
|
|
@ -163,7 +177,8 @@ class Core
|
|||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getAllLocales() {
|
||||
public function getAllLocales()
|
||||
{
|
||||
static $locales;
|
||||
|
||||
if($locales)
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use Illuminate\Support\Facades\Storage;
|
|||
|
||||
class Channel extends Model
|
||||
{
|
||||
protected $fillable = ['code', 'name', 'description', 'default_locale_id', 'base_currency_id', 'theme'];
|
||||
protected $fillable = ['code', 'name', 'description', 'theme', 'hostname', 'default_locale_id', 'base_currency_id'];
|
||||
|
||||
/**
|
||||
* Get the channel locales.
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\Core\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Routing\Router;
|
||||
use Illuminate\Foundation\AliasLoader;
|
||||
use Webkul\Core\Http\Middleware\Locale;
|
||||
use Webkul\Core\Core;
|
||||
use Webkul\Core\Facades\Core as CoreFacade;
|
||||
|
||||
|
|
@ -23,8 +24,6 @@ class CoreServiceProvider extends ServiceProvider
|
|||
|
||||
$this->loadTranslationsFrom(__DIR__ . '/../Resources/lang', 'core');
|
||||
|
||||
$router->aliasMiddleware('locale', Locale::class);
|
||||
|
||||
Validator::extend('slug', 'Webkul\Core\Contracts\Validations\Slug@passes');
|
||||
|
||||
Validator::extend('code', 'Webkul\Core\Contracts\Validations\Code@passes');
|
||||
|
|
|
|||
|
|
@ -1,15 +1,14 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\Core\Http\Middleware;
|
||||
namespace Webkul\Shop\Http\Middleware;
|
||||
|
||||
use Webkul\Core\Models\Locale as LocaleModel;
|
||||
use Webkul\Core\Repositories\LocaleRepository;
|
||||
use Closure;
|
||||
|
||||
class Locale
|
||||
{
|
||||
/**
|
||||
* @var \Webkul\Core\Repositories\LocaleRepository
|
||||
* @var LocaleRepository
|
||||
*/
|
||||
protected $locale;
|
||||
|
||||
|
|
@ -32,7 +31,13 @@ class Locale
|
|||
{
|
||||
if($locale = $request->get('locale')) {
|
||||
if($this->locale->findOneByField('code', $locale)) {
|
||||
// app()->setLocale($locale);
|
||||
app()->setLocale($locale);
|
||||
|
||||
session()->put('locale', $locale);
|
||||
}
|
||||
} else {
|
||||
if($locale = session()->get('locale')) {
|
||||
app()->setLocale($locale);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\Shop\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
|
||||
class Theme
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
$theme = app('themes');
|
||||
$channel = core()->getCurrentChannel();
|
||||
|
||||
if($channel && $channelThemeCode = $channel->theme) {
|
||||
if($theme->exists($channelThemeCode)) {
|
||||
$theme->set($channelThemeCode);
|
||||
}
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
Route::group(['middleware' => ['web']], function () {
|
||||
Route::group(['middleware' => ['web', 'theme', 'locale']], function () {
|
||||
|
||||
Route::get('/', 'Webkul\Shop\Http\Controllers\HomeController@index')->defaults('_config', [
|
||||
'view' => 'shop::home.index'
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ use Illuminate\Support\ServiceProvider;
|
|||
use Illuminate\Support\Facades\Event;
|
||||
use Illuminate\Routing\Router;
|
||||
use Illuminate\Support\Facades\Blade;
|
||||
use Webkul\Shop\Http\Middleware\Locale;
|
||||
use Webkul\Shop\Http\Middleware\Theme;
|
||||
use Webkul\Shop\Providers\ComposerServiceProvider;
|
||||
use Webkul\Ui\Menu;
|
||||
|
||||
|
|
@ -16,7 +18,7 @@ class ShopServiceProvider extends ServiceProvider
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
public function boot(Router $router)
|
||||
{
|
||||
include __DIR__ . '/../Http/routes.php';
|
||||
|
||||
|
|
@ -28,6 +30,10 @@ class ShopServiceProvider extends ServiceProvider
|
|||
|
||||
$this->loadViewsFrom(__DIR__ . '/../Resources/views', 'shop');
|
||||
|
||||
$router->aliasMiddleware('locale', Locale::class);
|
||||
|
||||
$router->aliasMiddleware('theme', Theme::class);
|
||||
|
||||
$this->app->register(ComposerServiceProvider::class);
|
||||
|
||||
$this->composeView();
|
||||
|
|
|
|||
|
|
@ -737,21 +737,19 @@ section.slider-block {
|
|||
}
|
||||
|
||||
.form-container {
|
||||
padding-top: 10px;
|
||||
padding-top: 5px;
|
||||
|
||||
.control-group {
|
||||
margin: 0;
|
||||
|
||||
.subscribe-field {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.subscribe-field::-webkit-input-placeholder {
|
||||
font-family: "montserrat", sans-serif;
|
||||
}
|
||||
&::-webkit-input-placeholder {
|
||||
font-family: "montserrat", sans-serif;
|
||||
}
|
||||
|
||||
.subscribe-field::-moz-placeholder {
|
||||
font-family: "montserrat", sans-serif;
|
||||
&::-moz-placeholder {
|
||||
font-family: "montserrat", sans-serif;
|
||||
}
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
|
|
@ -760,6 +758,10 @@ section.slider-block {
|
|||
border-radius: 0px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.locale-switcher {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,12 @@ return [
|
|||
]
|
||||
],
|
||||
|
||||
'footer' => [
|
||||
'subscribe-newsletter' => 'Subscribe Newsletter',
|
||||
'subscribe' => 'Subscribe',
|
||||
'locale' => 'Locale',
|
||||
],
|
||||
|
||||
'reviews' => [
|
||||
'add-review-page-title' => 'Add Review',
|
||||
'write-review' => 'Write a review',
|
||||
|
|
|
|||
|
|
@ -3,14 +3,17 @@
|
|||
<div class="footer-list-container">
|
||||
<div class="list-container">
|
||||
<span class="list-heading">Categories</span>
|
||||
|
||||
<ul class="list-group">
|
||||
@foreach($categories as $key => $category)
|
||||
<li>{{ $category['name'] }}</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="list-container">
|
||||
<span class="list-heading">Quick Links</span>
|
||||
|
||||
<ul class="list-group">
|
||||
<li>About Us</li>
|
||||
<li>Return Policy</li>
|
||||
|
|
@ -20,8 +23,10 @@
|
|||
<li>Contact Us</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="list-container">
|
||||
<span class="list-heading">Connect With Us</span>
|
||||
|
||||
<ul class="list-group">
|
||||
<li><span class="icon-wrapper"><span class="icon icon-dashboard"></span></span>Facebook</li>
|
||||
<li><span class="icon-wrapper"><span class="icon icon-dashboard"></span></span>Twitter</li>
|
||||
|
|
@ -31,12 +36,26 @@
|
|||
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="list-container">
|
||||
<span class="list-heading">Subscribe Newsletter</span>
|
||||
<span class="list-heading">{{ __('shop::app.footer.subscribe-newsletter') }}</span>
|
||||
<div class="form-container">
|
||||
<div class="control-group">
|
||||
<input type="text" class="control subscribe-field" placeholder="Email Address"><br/>
|
||||
<button class="btn btn-md btn-primary">Subscribe</button>
|
||||
<button class="btn btn-md btn-primary">{{ __('shop::app.footer.subscribe') }}</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<span class="list-heading">{{ __('shop::app.footer.locale') }}</span>
|
||||
<div class="form-container">
|
||||
<div class="control-group">
|
||||
<select class="control locale-switcher" onchange="window.location.href = this.value">
|
||||
|
||||
@foreach (core()->getCurrentChannel()->locales as $locale)
|
||||
<option value="?locale={{ $locale->code }}" {{ $locale->code == app()->getLocale() ? 'selected' : '' }}>{{ $locale->name }}</option>
|
||||
@endforeach
|
||||
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1402,11 +1402,7 @@ section.slider-block div.slider-content div.slider-control .light-right-icon {
|
|||
}
|
||||
|
||||
.footer .footer-content .footer-list-container .list-container .form-container {
|
||||
padding-top: 10px;
|
||||
}
|
||||
|
||||
.footer .footer-content .footer-list-container .list-container .form-container .control-group {
|
||||
margin: 0;
|
||||
padding-top: 5px;
|
||||
}
|
||||
|
||||
.footer .footer-content .footer-list-container .list-container .form-container .control-group .subscribe-field {
|
||||
|
|
@ -1428,6 +1424,10 @@ section.slider-block div.slider-content div.slider-control .light-right-icon {
|
|||
text-align: center;
|
||||
}
|
||||
|
||||
.footer .footer-content .footer-list-container .list-container .form-container .control-group .locale-switcher {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.main .category-container {
|
||||
display: -webkit-box;
|
||||
display: -ms-flexbox;
|
||||
|
|
|
|||
Loading…
Reference in New Issue