promotions and products

This commit is contained in:
merdan 2021-11-09 22:55:21 +05:00
parent 1c5dc4dd9d
commit a3139edfd2
37 changed files with 2275 additions and 652 deletions

1022
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -283,7 +283,8 @@ return [
Webkul\DebugBar\Providers\DebugBarServiceProvider::class,
Webkul\Marketing\Providers\MarketingServiceProvider::class,
Sarga\Shop\Providers\ShopServiceProvider::class,
Sarga\API\Providers\APIServiceProvider::class
Sarga\API\Providers\APIServiceProvider::class,
Sarga\Admin\Providers\AdminServiceProvider::class
],
/*

View File

@ -2,11 +2,24 @@
namespace Sarga\API\Http\Controllers;
use App\Http\Controllers\Controller;
use Sarga\API\Http\Resources\Catalog\Category;
use Webkul\API\Http\Controllers\Shop\CategoryController;
use Sarga\Shop\Repositories\CategoryRepository;
class Categories extends CategoryController
class Categories extends Controller
{
/**
* CategoryRepository object
*
* @var \Sarga\Shop\Repositories\CategoryRepository
*/
protected $categoryRepository;
public function __construct(CategoryRepository $categoryRepository)
{
$this->categoryRepository = $categoryRepository;
}
public function index()
{
return Category::collection(

View File

@ -30,7 +30,7 @@ class Channels extends Controller
}
public function get($channel_id){
$this->categoryRepository->getVisibleCategoryTree(request()->input('parent_id'));
$this->categoryRepository->getCategoryTreeWithoutDescendant(request()->input('parent_id'));
}
}

View File

@ -0,0 +1,35 @@
<?php
namespace Sarga\API\Http\Controllers;
use Webkul\API\Http\Controllers\Shop\ProductController;
use Sarga\API\Http\Resources\Catalog\Product as ProductResource;
class Products extends ProductController
{
/**
* Returns a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
return ProductResource::collection($this->productRepository->getAll(request()->input('category_id')));
}
/**
* Returns a individual resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function get($id)
{
return new ProductResource(
$this->productRepository->findOrFail($id)
);
}
}

View File

@ -19,11 +19,10 @@ class Category extends JsonResource
'id' => $this->id,
// 'code' => $this->code,
'name' => $this->name,
// 'slug' => $this->slug,
'slug' => $this->slug,
// 'display_mode' => $this->display_mode,
// 'description' => $this->description,
// 'status' => $this->status,
'menu' => $this->visible_in_menu,
'status' => $this->status,
'image_url' => $this->image_url,
'category_icon_path' => $this->category_icon_path
? Storage::url($this->category_icon_path)

View File

@ -0,0 +1,195 @@
<?php
namespace Sarga\API\Http\Resources\Catalog;
use Illuminate\Http\Resources\Json\JsonResource;
class Product extends JsonResource
{
/**
* Create a new resource instance.
*
* @return void
*/
public function __construct($resource)
{
// $this->productReviewHelper = app('Webkul\Product\Helpers\Review');
$this->wishlistHelper = app('Webkul\Customer\Helpers\Wishlist');
parent::__construct($resource);
}
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request
* @return array
*/
public function toArray($request)
{
/* assign product */
$product = $this->product ? $this->product : $this;
/* get type instance */
$productTypeInstance = $product->getTypeInstance();
/* generating resource */
return [
/* product's information */
'id' => $product->id,
// 'sku' => $product->sku,
'type' => $product->type,
'name' => $product->name,
'url_key' => $product->url_key,
'price' => $productTypeInstance->getMinimalPrice(),
'converted_price' => core()->convertPrice($productTypeInstance->getMinimalPrice()),
'short_description' => $product->short_description,
'description' => $product->description,
'images' => ProductImage::collection($product->images),
/* product's checks */
'in_stock' => $product->haveSufficientQuantity(1),
'is_wishlisted' => $this->wishlistHelper->getWishlistProduct($product) ? true : false,
'is_item_in_cart' => \Cart::hasProduct($product),
'show_quantity_changer' => $this->when(
$product->type !== 'grouped',
$product->getTypeInstance()->showQuantityBox()
),
/* product's extra information */
$this->merge($this->allProductExtraInfo()),
/* special price cases */
$this->merge($this->specialPriceInfo()),
/* super attributes */
$this->mergeWhen($productTypeInstance->isComposite(), [
'super_attributes' => Attribute::collection($product->super_attributes),
]),
];
}
/**
* Get special price information.
*
* @return array
*/
private function specialPriceInfo()
{
$product = $this->product ? $this->product : $this;
$productTypeInstance = $product->getTypeInstance();
return [
'special_price' => $this->when(
$productTypeInstance->haveSpecialPrice(),
$productTypeInstance->getSpecialPrice()
),
'formated_special_price' => $this->when(
$productTypeInstance->haveSpecialPrice(),
core()->currency($productTypeInstance->getSpecialPrice())
),
'regular_price' => $this->when(
$productTypeInstance->haveSpecialPrice(),
data_get($productTypeInstance->getProductPrices(), 'regular_price.price')
),
'formated_regular_price' => $this->when(
$productTypeInstance->haveSpecialPrice(),
data_get($productTypeInstance->getProductPrices(), 'regular_price.formated_price')
),
];
}
/**
* Get all product's extra information.
*
* @return array
*/
private function allProductExtraInfo()
{
$product = $this->product ? $this->product : $this;
$productTypeInstance = $product->getTypeInstance();
return [
/* grouped product */
$this->mergeWhen(
$productTypeInstance instanceof \Webkul\Product\Type\Grouped,
$product->type == 'grouped'
? $this->getGroupedProductInfo($product)
: null
),
/* bundle product */
$this->mergeWhen(
$productTypeInstance instanceof \Webkul\Product\Type\Bundle,
$product->type == 'bundle'
? $this->getBundleProductInfo($product)
: null
),
/* configurable product */
$this->mergeWhen(
$productTypeInstance instanceof \Webkul\Product\Type\Configurable,
$product->type == 'configurable'
? $this->getConfigurableProductInfo($product)
: null
),
];
}
/**
* Get grouped product's extra information.
*
* @param \Webkul\Product\Models\Product
* @return array
*/
private function getGroupedProductInfo($product)
{
return [
'grouped_products' => $product->grouped_products->map(function($groupedProduct) {
$associatedProduct = $groupedProduct->associated_product;
$data = $associatedProduct->toArray();
return array_merge($data, [
'qty' => $groupedProduct->qty,
'isSaleable' => $associatedProduct->getTypeInstance()->isSaleable(),
'formated_price' => $associatedProduct->getTypeInstance()->getPriceHtml(),
'show_quantity_changer' => $associatedProduct->getTypeInstance()->showQuantityBox(),
]);
})
];
}
/**
* Get bundle product's extra information.
*
* @param \Webkul\Product\Models\Product
* @return array
*/
private function getBundleProductInfo($product)
{
return [
'currency_options' => core()->getAccountJsSymbols(),
'bundle_options' => app('Webkul\Product\Helpers\BundleOption')->getBundleConfig($product)
];
}
/**
* Get configurable product's extra information.
*
* @param \Webkul\Product\Models\Product
* @return array
*/
private function getConfigurableProductInfo($product)
{
return [
'variants' => ProductVariant::collection($product->variants)
];
}
}

View File

@ -0,0 +1,23 @@
<?php
namespace Sarga\API\Http\Resources\Catalog;
use Illuminate\Http\Resources\Json\JsonResource;
class ProductImage extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request
* @return array
*/
public function toArray($request)
{
return [
'path' => $this->path,
'original_image_url' => $this->url,
'small_image_url' => url('cache/small/' . $this->path),
];
}
}

View File

@ -0,0 +1,43 @@
<?php
namespace Sarga\API\Http\Resources\Catalog;
use Illuminate\Http\Resources\Json\JsonResource;
class ProductVariant extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request
* @return array
*/
public function toArray($request)
{
/* assign product */
$product = $this->product ? $this->product : $this;
/* get type instance */
$productTypeInstance = $product->getTypeInstance();
return [
'id' => $this->id,
'parent_id' => $this->parent_id,
'additional' => $this->additional,
'price' => $productTypeInstance->getMinimalPrice(),
'converted_price' => core()->convertPrice($productTypeInstance->getMinimalPrice()),
"color" => $this->color,
"size"=>$this->size,
"brand"=>$this->brand,
"special_price"=> $this->special_price,
"special_price_from"=>$this->special_price_from,
"special_price_to"=>$this->special_price_to,
"length"=>$this->length,
"width"=>$this->width,
"height"=>$this->height,
"weight"=>$this->weight,
"quantity" => $this->inventories->sum('qty')
];
}
}

View File

@ -22,6 +22,7 @@ class Channel extends JsonResource
'name' => $this->name,
'hostname' => $this->hostname,
'root_category_id' => $this->root_category_id,
'promotion_category_id' => $this->promotion_category_id,
'is_maintenance_on' => $this->is_maintenance_on,
'sliders' => Slider::collection($this->sliders),
'brand_attribute_id' => 25 //todo vremenno goyuldy. id admindan bazadan settingsden almaly(2 marketplace goshulanda)

View File

@ -0,0 +1,20 @@
<?php
if (! function_exists('currency')) {
/**
* Core helper.
*
* @return \Webkul\Core\Core
*/
function currency($amount = 0)
{
$core = app()->make(\Webkul\Core\Core::class);
if (is_null($amount)) {
$amount = 0;
}
$formatter = new \NumberFormatter(app()->getLocale(), \NumberFormatter::CURRENCY);
return $formatter->formatCurrency($core->convertPrice($amount), $core->getCurrentCurrency()->code);
}
}

View File

@ -2,6 +2,7 @@
use Sarga\API\Http\Controllers\Categories;
use Sarga\API\Http\Controllers\Channels;
use Sarga\API\Http\Controllers\Products;
use Webkul\API\Http\Controllers\Shop\ResourceController;
use Webkul\Attribute\Repositories\AttributeOptionRepository;
use Sarga\API\Http\Resources\Catalog\AttributeOption;
@ -21,5 +22,9 @@ Route::group(['prefix' => 'api'], function ($router) {
'resource' => AttributeOption::class,
]);
//Product routes
Route::get('products', [Products::class, 'index']);
Route::get('products/{id}', [Products::class, 'get']);
});
});

View File

@ -12,6 +12,8 @@ class APIServiceProvider extends ServiceProvider
*/
public function boot(Router $router)
{
include __DIR__ . '/../Http/helpers.php';
$this->loadRoutesFrom(__DIR__.'/../Http/routes.php');
}
}

View File

@ -0,0 +1,27 @@
{
"name": "sarga/laravel-admin",
"license": "MIT",
"authors": [
{
"name": "Merdan Singh",
"email": "merdan.m@gmail.com"
}
],
"require": {
"bagisto/laravel-core": "dev-master"
},
"autoload": {
"psr-4": {
"Sarga\\Admin\\": "src/"
}
},
"extra": {
"laravel": {
"providers": [
"Sarga\\Admin\\Providers\\AdminServiceProvider"
],
"aliases": {}
}
},
"minimum-stability": "dev"
}

View File

@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddPromotionCategoryIdInChannelsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('channels', function (Blueprint $table) {
$table->integer('promotion_category_id')->nullable()->unsigned();
$table->foreign('promotion_category_id')->references('id')->on('categories')->onDelete('set null');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('channels', function (Blueprint $table) {
$table->dropColumn('promotion_category_id');
});
}
}

View File

@ -0,0 +1,23 @@
<?php
namespace Sarga\Admin\Providers;
use Illuminate\Routing\Router;
use Illuminate\Support\ServiceProvider;
use Webkul\Admin\Http\Middleware\Locale;
use Webkul\Core\Tree;
class AdminServiceProvider extends ServiceProvider
{
/**
* Bootstrap services.
*
* @return void
*/
public function boot(Router $router)
{
$this->loadRoutesFrom(__DIR__ . '/../Routes/settings-routes.php');
$this->loadViewsFrom(__DIR__ . '/../Resources/views', 'sarga_admin');
$this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations');
}
}

View File

@ -0,0 +1,270 @@
@extends('admin::layouts.content')
@section('page_title')
{{ __('admin::app.settings.channels.add-title') }}
@stop
@section('content')
<div class="content">
<form method="POST" action="{{ route('admin.channels.store') }}" @submit.prevent="onSubmit" enctype="multipart/form-data">
<div class="page-header">
<div class="page-title">
<h1>
<i class="icon angle-left-icon back-link" onclick="window.location = '{{ route('admin.channels.index') }}'"></i>
{{ __('admin::app.settings.channels.add-title') }}
</h1>
</div>
<div class="page-action">
<button type="submit" class="btn btn-lg btn-primary">
{{ __('admin::app.settings.channels.save-btn-title') }}
</button>
</div>
</div>
<div class="page-content">
<div class="form-container">
@csrf()
{!! view_render_event('bagisto.admin.settings.channel.create.before') !!}
{{-- general --}}
<accordian :title="'{{ __('admin::app.settings.channels.general') }}'" :active="true">
<div slot="body">
<div class="control-group" :class="[errors.has('code') ? 'has-error' : '']">
<label for="code" class="required">{{ __('admin::app.settings.channels.code') }}</label>
<input v-validate="'required'" class="control" id="code" name="code" value="{{ old('code') }}" data-vv-as="&quot;{{ __('admin::app.settings.channels.code') }}&quot;" v-code/>
<span class="control-error" v-if="errors.has('code')">@{{ errors.first('code') }}</span>
</div>
<div class="control-group" :class="[errors.has('name') ? 'has-error' : '']">
<label for="name" class="required">{{ __('admin::app.settings.channels.name') }}</label>
<input v-validate="'required'" class="control" id="name" name="name" data-vv-as="&quot;{{ __('admin::app.settings.channels.name') }}&quot;" value="{{ old('name') }}"/>
<span class="control-error" v-if="errors.has('name')">@{{ errors.first('name') }}</span>
</div>
<div class="control-group">
<label for="description">{{ __('admin::app.settings.channels.description') }}</label>
<textarea class="control" id="description" name="description">{{ old('description') }}</textarea>
</div>
<div class="control-group" :class="[errors.has('inventory_sources[]') ? 'has-error' : '']">
<label for="inventory_sources" class="required">{{ __('admin::app.settings.channels.inventory_sources') }}</label>
<select v-validate="'required'" class="control" id="inventory_sources" name="inventory_sources[]" data-vv-as="&quot;{{ __('admin::app.settings.channels.inventory_sources') }}&quot;" multiple>
@foreach (app('Webkul\Inventory\Repositories\InventorySourceRepository')->findWhere(['status' => 1]) as $inventorySource)
<option value="{{ $inventorySource->id }}" {{ old('inventory_sources') && in_array($inventorySource->id, old('inventory_sources')) ? 'selected' : '' }}>
{{ $inventorySource->name }}
</option>
@endforeach
</select>
<span class="control-error" v-if="errors.has('inventory_sources[]')">@{{ errors.first('inventory_sources[]') }}</span>
</div>
<div class="control-group" :class="[errors.has('root_category_id') ? 'has-error' : '']">
<label for="root_category_id" class="required">{{ __('admin::app.settings.channels.root-category') }}</label>
<select v-validate="'required'" class="control" id="root_category_id" name="root_category_id" data-vv-as="&quot;{{ __('admin::app.settings.channels.root-category') }}&quot;">
@foreach (app('Webkul\Category\Repositories\CategoryRepository')->getRootCategories() as $category)
<option value="{{ $category->id }}" {{ old('root_category_id') == $category->id ? 'selected' : '' }}>
{{ $category->name }}
</option>
@endforeach
</select>
<span class="control-error" v-if="errors.has('root_category_id')">@{{ errors.first('root_category_id') }}</span>
</div>
<div class="control-group" :class="[errors.has('promotion_category_id') ? 'has-error' : '']">
<label for="promotion_category_id" class="required">{{ __('admin::app.settings.channels.root-category') }}</label>
<select v-validate="'required'" class="control" id="promotion_category_id" name="promotion_category_id" data-vv-as="&quot;{{ __('admin::app.settings.channels.root-category') }}&quot;">
@foreach (app('Sarga\Shop\Repositories\CategoryRepository')->getDescriptionCategories() as $category)
<option value="{{ $category->id }}" {{ old('promotion_category_id') == $category->id ? 'selected' : '' }}>
{{ $category->id }} - {{ $category->name }}
</option>
@endforeach
</select>
<span class="control-error" v-if="errors.has('promotion_category_id')">@{{ errors.first('promotion_category_id') }}</span>
</div>
<div class="control-group" :class="[errors.has('hostname') ? 'has-error' : '']">
<label for="hostname">{{ __('admin::app.settings.channels.hostname') }}</label>
<input class="control" v-validate="''" id="hostname" name="hostname" value="{{ old('hostname') }}" placeholder="{{ __('admin::app.settings.channels.hostname-placeholder') }}"/>
<span class="control-error" v-if="errors.has('hostname')">@{{ errors.first('hostname') }}</span>
</div>
</div>
</accordian>
{{-- currencies and locales --}}
<accordian :title="'{{ __('admin::app.settings.channels.currencies-and-locales') }}'" :active="true">
<div slot="body">
<div class="control-group" :class="[errors.has('locales[]') ? 'has-error' : '']">
<label for="locales" class="required">{{ __('admin::app.settings.channels.locales') }}</label>
<select v-validate="'required'" class="control" id="locales" name="locales[]" data-vv-as="&quot;{{ __('admin::app.settings.channels.locales') }}&quot;" multiple>
@foreach (core()->getAllLocales() as $locale)
<option value="{{ $locale->id }}" {{ old('locales') && in_array($locale->id, old('locales')) ? 'selected' : '' }}>
{{ $locale->name }}
</option>
@endforeach
</select>
<span class="control-error" v-if="errors.has('locales[]')">@{{ errors.first('locales[]') }}</span>
</div>
<div class="control-group" :class="[errors.has('default_locale_id') ? 'has-error' : '']">
<label for="default_locale_id" class="required">{{ __('admin::app.settings.channels.default-locale') }}</label>
<select v-validate="'required'" class="control" id="default_locale_id" name="default_locale_id" data-vv-as="&quot;{{ __('admin::app.settings.channels.default-locale') }}&quot;">
@foreach (core()->getAllLocales() as $locale)
<option value="{{ $locale->id }}" {{ old('default_locale_id') == $locale->id ? 'selected' : '' }}>
{{ $locale->name }}
</option>
@endforeach
</select>
<span class="control-error" v-if="errors.has('default_locale_id')">@{{ errors.first('default_locale_id') }}</span>
</div>
<div class="control-group" :class="[errors.has('currencies[]') ? 'has-error' : '']">
<label for="currencies" class="required">{{ __('admin::app.settings.channels.currencies') }}</label>
<select v-validate="'required'" class="control" id="currencies" name="currencies[]" data-vv-as="&quot;{{ __('admin::app.settings.channels.currencies') }}&quot;" multiple>
@foreach (core()->getAllCurrencies() as $currency)
<option value="{{ $currency->id }}" {{ old('currencies') && in_array($currency->id, old('currencies')) ? 'selected' : '' }}>
{{ $currency->name }}
</option>
@endforeach
</select>
<span class="control-error" v-if="errors.has('currencies[]')">@{{ errors.first('currencies[]') }}</span>
</div>
<div class="control-group" :class="[errors.has('base_currency_id') ? 'has-error' : '']">
<label for="base_currbase_currency_idency" class="required">{{ __('admin::app.settings.channels.base-currency') }}</label>
<select v-validate="'required'" class="control" id="base_currency_id" name="base_currency_id" data-vv-as="&quot;{{ __('admin::app.settings.channels.base-currency') }}&quot;">
@foreach (core()->getAllCurrencies() as $currency)
<option value="{{ $currency->id }}" {{ old('base_currency_id') == $currency->id ? 'selected' : '' }}>
{{ $currency->name }}
</option>
@endforeach
</select>
<span class="control-error" v-if="errors.has('base_currency_id')">@{{ errors.first('base_currency_id') }}</span>
</div>
</div>
</accordian>
{{-- design --}}
<accordian :title="'{{ __('admin::app.settings.channels.design') }}'" :active="true">
<div slot="body">
<div class="control-group">
<label for="theme">{{ __('admin::app.settings.channels.theme') }}</label>
<select class="control" id="theme" name="theme">
@foreach (config('themes.themes') as $themeCode => $theme)
<option value="{{ $themeCode }}" {{ old('theme') == $themeCode ? 'selected' : '' }}>
{{ $theme['name'] }}
</option>
@endforeach
</select>
</div>
<div class="control-group">
<label for="home_page_content">{{ __('admin::app.settings.channels.home_page_content') }}</label>
<textarea class="control" id="home_page_content" name="home_page_content">{{ old('home_page_content') }}</textarea>
</div>
<div class="control-group">
<label for="footer_content">{{ __('admin::app.settings.channels.footer_content') }}</label>
<textarea class="control" id="footer_content" name="footer_content">{{ old('footer_content') }}</textarea>
</div>
<div class="control-group">
<label>{{ __('admin::app.settings.channels.logo') }}</label>
<image-wrapper :button-label="'{{ __('admin::app.catalog.products.add-image-btn-title') }}'" input-name="logo" :multiple="false"></image-wrapper>
</div>
<div class="control-group">
<label>{{ __('admin::app.settings.channels.favicon') }}</label>
<image-wrapper :button-label="'{{ __('admin::app.catalog.products.add-image-btn-title') }}'" input-name="logo" :multiple="false"></image-wrapper>
</div>
</div>
</accordian>
{{-- home page seo --}}
<accordian :title="'{{ __('admin::app.settings.channels.seo') }}'" :active="true">
<div slot="body">
<div class="control-group" :class="[errors.has('seo_title') ? 'has-error' : '']">
<label for="seo_title" class="required">{{ __('admin::app.settings.channels.seo-title') }}</label>
<input v-validate="'required'" class="control" id="seo_title" name="seo_title" data-vv-as="&quot;{{ __('admin::app.settings.channels.seo-title') }}&quot;" value="{{ old('seo_title') }}"/>
<span class="control-error" v-if="errors.has('seo_title')">@{{ errors.first('seo_title') }}</span>
</div>
<div class="control-group" :class="[errors.has('seo_description') ? 'has-error' : '']">
<label for="seo_description" class="required">{{ __('admin::app.settings.channels.seo-description') }}</label>
<textarea v-validate="'required'" class="control" id="seo_description" name="seo_description" data-vv-as="&quot;{{ __('admin::app.settings.channels.seo-description') }}&quot;" value="{{ old('seo_description') }}"></textarea>
<span class="control-error" v-if="errors.has('seo_description')">@{{ errors.first('seo_description') }}</span>
</div>
<div class="control-group" :class="[errors.has('seo_keywords') ? 'has-error' : '']">
<label for="seo_keywords" class="required">{{ __('admin::app.settings.channels.seo-keywords') }}</label>
<textarea v-validate="'required'" class="control" id="seo_keywords" name="seo_keywords" data-vv-as="&quot;{{ __('admin::app.settings.channels.seo-keywords') }}&quot;" value="{{ old('seo_keywords') }}"></textarea>
<span class="control-error" v-if="errors.has('seo_keywords')">@{{ errors.first('seo_keywords') }}</span>
</div>
</div>
</accordian>
{{-- maintenance mode --}}
<accordian title="{{ __('admin::app.settings.channels.maintenance-mode') }}" :active="true">
<div slot="body">
<div class="control-group">
<label for="maintenance-mode-status">{{ __('admin::app.status') }}</label>
<label class="switch">
<input type="hidden" name="is_maintenance_on" value="0" />
<input type="checkbox" id="maintenance-mode-status" name="is_maintenance_on" value="1">
<span class="slider round"></span>
</label>
</div>
<div class="control-group">
<label for="maintenance-mode-text">{{ __('admin::app.settings.channels.maintenance-mode-text') }}</label>
<input class="control" id="maintenance-mode-text" name="maintenance_mode_text" value=""/>
</div>
<div class="control-group">
<label for="allowed-ips">{{ __('admin::app.settings.channels.allowed-ips') }}</label>
<input class="control" id="allowed-ips" name="allowed_ips" value=""/>
</div>
</div>
</accordian>
{!! view_render_event('bagisto.admin.settings.channel.create.after') !!}
</div>
</div>
</form>
</div>
@stop
@push('scripts')
@include('admin::layouts.tinymce')
<script>
$(document).ready(function () {
tinyMCEHelper.initTinyMCE({
selector: 'textarea#home_page_content,textarea#footer_content',
height: 200,
width: "100%",
plugins: 'image imagetools media wordcount save fullscreen code table lists link hr',
toolbar1: 'formatselect | bold italic strikethrough forecolor backcolor link hr | alignleft aligncenter alignright alignjustify | numlist bullist outdent indent | removeformat | code | table',
image_advtab: true,
valid_elements : '*[*]',
uploadRoute: '{{ route('admin.tinymce.upload') }}',
csrfToken: '{{ csrf_token() }}',
});
});
</script>
@endpush

View File

@ -0,0 +1,325 @@
@extends('admin::layouts.content')
@section('page_title')
{{ __('admin::app.settings.channels.edit-title') }}
@stop
@section('content')
<div class="content">
@php $locale = core()->getRequestedLocaleCode(); @endphp
<form method="POST" action="{{ route('admin.channels.update', ['id' => $channel->id, 'locale' => $locale]) }}" @submit.prevent="onSubmit" enctype="multipart/form-data">
<div class="page-header">
<div class="page-title">
<h1>
<i class="icon angle-left-icon back-link" onclick="window.location = '{{ route('admin.channels.index') }}'"></i>
{{ __('admin::app.settings.channels.edit-title') }}
</h1>
<div class="control-group">
<select class="control" id="locale-switcher" onChange="window.location.href = this.value">
@foreach (core()->getAllLocales() as $localeModel)
<option value="{{ route('admin.channels.edit', $channel->id) . '?locale=' . $localeModel->code }}" {{ ($localeModel->code) == $locale ? 'selected' : '' }}>
{{ $localeModel->name }}
</option>
@endforeach
</select>
</div>
</div>
<div class="page-action">
<button type="submit" class="btn btn-lg btn-primary">
{{ __('admin::app.settings.channels.save-btn-title') }}
</button>
</div>
</div>
<div class="page-content">
<div class="form-container">
@csrf()
<input name="_method" type="hidden" value="PUT">
{!! view_render_event('bagisto.admin.settings.channel.edit.before') !!}
{{-- general --}}
<accordian :title="'{{ __('admin::app.settings.channels.general') }}'" :active="true">
<div slot="body">
<div class="control-group" :class="[errors.has('code') ? 'has-error' : '']">
<label for="code" class="required">{{ __('admin::app.settings.channels.code') }}</label>
<input type="text" v-validate="'required'" class="control" id="code" name="code" data-vv-as="&quot;{{ __('admin::app.settings.channels.code') }}&quot;" value="{{ $channel->code }}" disabled="disabled"/>
<input type="hidden" name="code" value="{{ $channel->code }}"/>
<span class="control-error" v-if="errors.has('code')">@{{ errors.first('code') }}</span>
</div>
<div class="control-group" :class="[errors.has('{{$locale}}[name]') ? 'has-error' : '']">
<label for="name" class="required">
{{ __('admin::app.settings.channels.name') }}
<span class="locale">[{{ $locale }}]</span>
</label>
<input v-validate="'required'" class="control" id="name" name="{{$locale}}[name]" data-vv-as="&quot;{{ __('admin::app.settings.channels.name') }}&quot;" value="{{ old($locale)['name'] ?? ($channel->translate($locale)['name'] ?? $channel->name) }}"/>
<span class="control-error" v-if="errors.has('{{$locale}}[name]')">@{{ errors.first('{!!$locale!!}[page_title]') }}</span>
</div>
<div class="control-group">
<label for="description">
{{ __('admin::app.settings.channels.description') }}
<span class="locale">[{{ $locale }}]</span>
</label>
<textarea class="control" id="description" name="{{$locale}}[description]">{{ old($locale)['description'] ?? ($channel->translate($locale)['description'] ?? $channel->description) }}</textarea>
</div>
<div class="control-group" :class="[errors.has('inventory_sources[]') ? 'has-error' : '']">
<label for="inventory_sources" class="required">{{ __('admin::app.settings.channels.inventory_sources') }}</label>
<?php $selectedOptionIds = old('inventory_sources') ?: $channel->inventory_sources->pluck('id')->toArray() ?>
<select v-validate="'required'" class="control" id="inventory_sources" name="inventory_sources[]" data-vv-as="&quot;{{ __('admin::app.settings.channels.inventory_sources') }}&quot;" multiple>
@foreach (app('Webkul\Inventory\Repositories\InventorySourceRepository')->findWhere(['status' => 1]) as $inventorySource)
<option value="{{ $inventorySource->id }}" {{ in_array($inventorySource->id, $selectedOptionIds) ? 'selected' : '' }}>
{{ $inventorySource->name }}
</option>
@endforeach
</select>
<span class="control-error" v-if="errors.has('inventory_sources[]')">@{{ errors.first('inventory_sources[]') }}</span>
</div>
<div class="control-group" :class="[errors.has('root_category_id') ? 'has-error' : '']">
<label for="root_category_id" class="required">{{ __('admin::app.settings.channels.root-category') }}</label>
<?php $selectedOption = old('root_category_id') ?: $channel->root_category_id ?>
<select v-validate="'required'" class="control" id="root_category_id" name="root_category_id" data-vv-as="&quot;{{ __('admin::app.settings.channels.root-category') }}&quot;">
@foreach (app('Webkul\Category\Repositories\CategoryRepository')->getRootCategories() as $category)
<option value="{{ $category->id }}" {{ $selectedOption == $category->id ? 'selected' : '' }}>
{{ $category->id }} - {{ $category->name }}
</option>
@endforeach
</select>
<span class="control-error" v-if="errors.has('root_category_id')">@{{ errors.first('root_category_id') }}</span>
</div>
<div class="control-group" :class="[errors.has('promotion_category_id') ? 'has-error' : '']">
<label for="promotion_category_id" class="required">Promotion Category</label>
<select v-validate="'required'" class="control" id="promotion_category_id" name="promotion_category_id" data-vv-as="&quot;{{ __('Promotion Category') }}&quot;">
<?php $selectedOption = old('promotion_category_id') ?: $channel->promotion_category_id ?>
@foreach (app('Sarga\Shop\Repositories\CategoryRepository')->getDescriptionCategories() as $category)
<option value="{{ $category->id }}" {{ old('promotion_category_id') == $category->id ? 'selected' : '' }}>
{{ $category->name }}
</option>
@endforeach
</select>
<span class="control-error" v-if="errors.has('promotion_category_id')">@{{ errors.first('promotion_category_id') }}</span>
</div>
<div class="control-group" :class="[errors.has('hostname') ? 'has-error' : '']">
<label for="hostname">{{ __('admin::app.settings.channels.hostname') }}</label>
<input type="text" v-validate="''" class="control" id="hostname" name="hostname" value="{{ $channel->hostname }}" placeholder="{{ __('admin::app.settings.channels.hostname-placeholder') }}"/>
<span class="control-error" v-if="errors.has('hostname')">@{{ errors.first('hostname') }}</span>
</div>
</div>
</accordian>
{{-- currencies and locales --}}
<accordian :title="'{{ __('admin::app.settings.channels.currencies-and-locales') }}'" :active="true">
<div slot="body">
<div class="control-group" :class="[errors.has('locales[]') ? 'has-error' : '']">
<label for="locales" class="required">{{ __('admin::app.settings.channels.locales') }}</label>
<?php $selectedOptionIds = old('locales') ?: $channel->locales->pluck('id')->toArray() ?>
<select v-validate="'required'" class="control" id="locales" name="locales[]" data-vv-as="&quot;{{ __('admin::app.settings.channels.locales') }}&quot;" multiple>
@foreach (core()->getAllLocales() as $localeModel)
<option value="{{ $localeModel->id }}" {{ in_array($localeModel->id, $selectedOptionIds) ? 'selected' : '' }}>
{{ $localeModel->name }}
</option>
@endforeach
</select>
<span class="control-error" v-if="errors.has('locales[]')">@{{ errors.first('locales[]') }}</span>
</div>
<div class="control-group" :class="[errors.has('default_locale_id') ? 'has-error' : '']">
<label for="default_locale_id" class="required">{{ __('admin::app.settings.channels.default-locale') }}</label>
<?php $selectedOption = old('default_locale_id') ?: $channel->default_locale_id ?>
<select v-validate="'required'" class="control" id="default_locale_id" name="default_locale_id" data-vv-as="&quot;{{ __('admin::app.settings.channels.default-locale') }}&quot;">
@foreach (core()->getAllLocales() as $localeModel)
<option value="{{ $localeModel->id }}" {{ $selectedOption == $localeModel->id ? 'selected' : '' }}>
{{ $localeModel->name }}
</option>
@endforeach
</select>
<span class="control-error" v-if="errors.has('default_locale_id')">@{{ errors.first('default_locale_id') }}</span>
</div>
<div class="control-group" :class="[errors.has('currencies[]') ? 'has-error' : '']">
<label for="currencies" class="required">{{ __('admin::app.settings.channels.currencies') }}</label>
<?php $selectedOptionIds = old('currencies') ?: $channel->currencies->pluck('id')->toArray() ?>
<select v-validate="'required'" class="control" id="currencies" name="currencies[]" data-vv-as="&quot;{{ __('admin::app.settings.channels.currencies') }}&quot;" multiple>
@foreach (core()->getAllCurrencies() as $currency)
<option value="{{ $currency->id }}" {{ in_array($currency->id, $selectedOptionIds) ? 'selected' : '' }}>
{{ $currency->name }}
</option>
@endforeach
</select>
<span class="control-error" v-if="errors.has('currencies[]')">@{{ errors.first('currencies[]') }}</span>
</div>
<div class="control-group" :class="[errors.has('base_currency_id') ? 'has-error' : '']">
<label for="base_currency_id" class="required">{{ __('admin::app.settings.channels.base-currency') }}</label>
<?php $selectedOption = old('base_currency_id') ?: $channel->base_currency_id ?>
<select v-validate="'required'" class="control" id="base_currency_id" name="base_currency_id" data-vv-as="&quot;{{ __('admin::app.settings.channels.base-currency') }}&quot;">
@foreach (core()->getAllCurrencies() as $currency)
<option value="{{ $currency->id }}" {{ $selectedOption == $currency->id ? 'selected' : '' }}>
{{ $currency->name }}
</option>
@endforeach
</select>
<span class="control-error" v-if="errors.has('base_currency_id')">@{{ errors.first('base_currency_id') }}</span>
</div>
</div>
</accordian>
{{-- design --}}
<accordian :title="'{{ __('admin::app.settings.channels.design') }}'" :active="true">
<div slot="body">
<div class="control-group">
<label for="theme">{{ __('admin::app.settings.channels.theme') }}</label>
<?php $selectedOption = old('theme') ?: $channel->theme ?>
<select class="control" id="theme" name="theme">
@foreach (config('themes.themes') as $themeCode => $theme)
<option value="{{ $themeCode }}" {{ $selectedOption == $themeCode ? 'selected' : '' }}>
{{ $theme['name'] }}
</option>
@endforeach
</select>
</div>
<div class="control-group">
<label for="home_page_content">
{{ __('admin::app.settings.channels.home_page_content') }}
<span class="locale">[{{ $locale }}]</span>
</label>
<textarea class="control" id="home_page_content" name="{{$locale}}[home_page_content]">{{ old($locale)['home_page_content'] ?? ($channel->translate($locale)['home_page_content'] ?? $channel->home_page_content) }}</textarea>
</div>
<div class="control-group">
<label for="footer_content">
{{ __('admin::app.settings.channels.footer_content') }}
<span class="locale">[{{ $locale }}]</span>
</label>
<textarea class="control" id="footer_content" name="{{$locale}}[footer_content]">{{ old($locale)['footer_content'] ?? ($channel->translate($locale)['footer_content'] ?? $channel->footer_content) }}</textarea>
</div>
<div class="control-group">
<label>{{ __('admin::app.settings.channels.logo') }}</label>
<image-wrapper :button-label="'{{ __('admin::app.catalog.products.add-image-btn-title') }}'" input-name="logo" :multiple="false" :images='"{{ $channel->logo_url }}"'></image-wrapper>
</div>
<div class="control-group">
<label>{{ __('admin::app.settings.channels.favicon') }}</label>
<image-wrapper :button-label="'{{ __('admin::app.catalog.products.add-image-btn-title') }}'" input-name="favicon" :multiple="false" :images='"{{ $channel->favicon_url }}"'></image-wrapper>
</div>
</div>
</accordian>
@php
$home_seo = $channel->translate($locale)['home_seo'] ?? $channel->home_seo;
$seo = json_decode($home_seo);
@endphp
{{-- home page seo --}}
<accordian :title="'{{ __('admin::app.settings.channels.seo') }}'" :active="true">
<div slot="body">
<div class="control-group" :class="[errors.has('{{$locale}}[seo_title]') ? 'has-error' : '']">
<label for="seo_title" class="required">
{{ __('admin::app.settings.channels.seo-title') }}
<span class="locale">[{{ $locale }}]</span>
</label>
<input v-validate="'required'" class="control" id="seo_title" name="{{$locale}}[seo_title]" data-vv-as="&quot;{{ __('admin::app.settings.channels.seo-title') }}&quot;" value="{{ $seo->meta_title ?? (old($locale)['seo_title'] ?? '') }}"/>
<span class="control-error" v-if="errors.has('{{$locale}}[seo_title]')">@{{ errors.first('{!!$locale!!}[page_title]') }}</span>
</div>
<div class="control-group" :class="[errors.has('{{$locale}}[seo_description]') ? 'has-error' : '']">
<label for="seo_description" class="required">
{{ __('admin::app.settings.channels.seo-description') }}
<span class="locale">[{{ $locale }}]</span>
</label>
<textarea v-validate="'required'" class="control" id="seo_description" name="{{$locale}}[seo_description]" data-vv-as="&quot;{{ __('admin::app.settings.channels.seo-description') }}&quot;">{{ $seo->meta_description ?? (old($locale)['seo_description'] ?? '') }}</textarea>
<span class="control-error" v-if="errors.has('{{$locale}}[seo_description]')">@{{ errors.first('{!!$locale!!}[page_title]') }}</span>
</div>
<div class="control-group" :class="[errors.has('{{$locale}}[seo_keywords]') ? 'has-error' : '']">
<label for="seo_keywords" class="required">
{{ __('admin::app.settings.channels.seo-keywords') }}
<span class="locale">[{{ $locale }}]</span>
</label>
<textarea v-validate="'required'" class="control" id="seo_keywords" name="{{$locale}}[seo_keywords]" data-vv-as="&quot;{{ __('admin::app.settings.channels.seo-keywords') }}&quot;">{{ $seo->meta_keywords ?? (old($locale)['seo_keywords'] ?? '') }}</textarea>
<span class="control-error" v-if="errors.has('{{$locale}}[seo_keywords]')">@{{ errors.first('{!!$locale!!}[page_title]') }}</span>
</div>
</div>
</accordian>
{{-- maintenance mode --}}
<accordian title="{{ __('admin::app.settings.channels.maintenance-mode') }}" :active="true">
<div slot="body">
<div class="control-group">
<label for="maintenance-mode-status">{{ __('admin::app.status') }}</label>
<label class="switch">
<input type="hidden" name="is_maintenance_on" value="0" />
<input type="checkbox" id="maintenance-mode-status" name="is_maintenance_on" value="1" {{ $channel->is_maintenance_on ? 'checked' : '' }}>
<span class="slider round"></span>
</label>
</div>
<div class="control-group">
<label for="maintenance-mode-text">
{{ __('admin::app.settings.channels.maintenance-mode-text') }}
<span class="locale">[{{ $locale }}]</span>
</label>
<input class="control" id="maintenance-mode-text" name="{{$locale}}[maintenance_mode_text]" value="{{ old('maintenance_mode_text') ?? ($channel->translate($locale)['maintenance_mode_text'] ?? $channel->maintenance_mode_text) }}"/>
</div>
<div class="control-group">
<label for="allowed-ips">{{ __('admin::app.settings.channels.allowed-ips') }}</label>
<input class="control" id="allowed-ips" name="allowed_ips" value="{{ old('allowed_ips') ?: $channel->allowed_ips }}"/>
</div>
</div>
</accordian>
{!! view_render_event('bagisto.admin.settings.channel.edit.after') !!}
</div>
</div>
</form>
</div>
@stop
@push('scripts')
@include('admin::layouts.tinymce')
<script>
$(document).ready(function () {
tinyMCEHelper.initTinyMCE({
selector: 'textarea#home_page_content,textarea#footer_content',
height: 200,
width: "100%",
plugins: 'image imagetools media wordcount save fullscreen code table lists link hr',
toolbar1: 'formatselect | bold italic strikethrough forecolor backcolor link hr | alignleft aligncenter alignright alignjustify | numlist bullist outdent indent | removeformat | code | table',
image_advtab: true,
valid_elements : '*[*]',
uploadRoute: '{{ route('admin.tinymce.upload') }}',
csrfToken: '{{ csrf_token() }}',
});
});
</script>
@endpush

View File

@ -0,0 +1,21 @@
<?php
use Illuminate\Support\Facades\Route;
use Webkul\Core\Http\Controllers\ChannelController;
/**
* Settings routes.
*/
Route::group(['middleware' => ['web', 'admin', 'admin_locale'], 'prefix' => config('app.admin_url')], function () {
/**
* Channels routes.
*/
Route::get('/channels/create', [ChannelController::class, 'create'])->defaults('_config', [
'view' => 'sarga_admin::settings.channels.create',
])->name('admin.channels.create');
Route::get('/channels/edit/{id}', [ChannelController::class, 'edit'])->defaults('_config', [
'view' => 'sarga_admin::settings.channels.edit',
])->name('admin.channels.edit');
});

View File

@ -0,0 +1,7 @@
[
{
"id":1,
"code":"TM",
"name":"Turkmenistan"
}
]

View File

@ -0,0 +1,10 @@
[
{
"country_id":1,
"name":"Турция"
},
{
"country_id":2,
"name":"Туркменистан"
}
]

View File

@ -0,0 +1,10 @@
[
{
"country_id":1,
"name":"Turkiýa"
},
{
"country_id":2,
"name":"Türkmenistan"
}
]

View File

@ -0,0 +1,44 @@
[
{
"id":1,
"country_code":"TM",
"code":"ASH",
"default_name":"Aşkabat",
"country_id":1
},
{
"id":2,
"country_code":"TM",
"code":"AH",
"default_name":"Ahal",
"country_id":1
},
{
"id":3,
"country_code":"TM",
"code":"BN",
"default_name":"Balkan",
"country_id":1
},
{
"id":4,
"country_code":"TM",
"code":"DZ",
"default_name":"Daşoguz",
"country_id":1
},
{
"id":5,
"country_code":"TM",
"code":"LB",
"default_name":"Lebap",
"country_id":1
},
{
"id":6,
"country_code":"TM",
"code":"MR",
"default_name":"Mari",
"country_id":1
}
]

View File

@ -0,0 +1,26 @@
[
{
"country_state_id":1,
"default_name":"Ашхабад"
},
{
"country_state_id":2,
"default_name":"Ахал"
},
{
"country_state_id":3,
"default_name":"Балкан"
},
{
"country_state_id":4,
"default_name":"Дашогуз"
},
{
"country_state_id":5,
"default_name":"Лебап"
},
{
"country_state_id":6,
"default_name":"Мары"
}
]

View File

@ -0,0 +1,26 @@
[
{
"country_state_id":1,
"default_name":"Aşgabat"
},
{
"country_state_id":2,
"default_name":"Ahal"
},
{
"country_state_id":3,
"default_name":"Balkan"
},
{
"country_state_id":4,
"default_name":"Daşoguz"
},
{
"country_state_id":5,
"default_name":"Lebap"
},
{
"country_state_id":6,
"default_name":"Mary"
}
]

View File

@ -0,0 +1,185 @@
<?php
namespace Sarga\Shop\Database\Seeders;
use Carbon\Carbon;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
/*
* Category table seeder.
*
* Command: php artisan db:seed --class=Webkul\\Category\\Database\\Seeders\\CategoryTableSeeder
*/
class CategoryTableSeeder extends Seeder
{
public function run()
{
DB::table('categories')->delete();
DB::table('category_translations')->delete();
$now = Carbon::now();
DB::table('categories')->insert([
[
'id' => '1',
'position' => '1',
'image' => NULL,
'status' => '1',
'_lft' => '1',
'_rgt' => '14',
'parent_id' => NULL,
'created_at' => $now,
'updated_at' => $now,
],
[
'id' => '2',
'position' => '2',
'image' => NULL,
'status' => '1',
'_lft' => '1',
'_rgt' => '14',
'parent_id' => NULL,
'created_at' => $now,
'updated_at' => $now,
],
[
'id' => '3',
'position' => '3',
'image' => NULL,
'status' => '1',
'_lft' => '1',
'_rgt' => '14',
'parent_id' => NULL,
'created_at' => $now,
'updated_at' => $now,
]
]);
DB::table('category_translations')->insert([
[
'name' => 'Trendyol',
'slug' => 'trendyol',
'description' => 'Trendyol',
'meta_title' => '',
'meta_description' => '',
'meta_keywords' => '',
'category_id' => '1',
'locale' => 'en',
],
[
'name' => 'Trendyol',
'slug' => 'trendyol',
'description' => 'Trendyol',
'meta_title' => '',
'meta_description' => '',
'meta_keywords' => '',
'category_id' => '1',
'locale' => 'ru',
],
[
'name' => 'Trendyol',
'slug' => 'trendyol',
'description' => 'Trendyol',
'meta_title' => '',
'meta_description' => '',
'meta_keywords' => '',
'category_id' => '1',
'locale' => 'tm',
],
[
'name' => 'Trendyol',
'slug' => 'trendyol',
'description' => 'Trendyol',
'meta_title' => '',
'meta_description' => '',
'meta_keywords' => '',
'category_id' => '1',
'locale' => 'tr',
],
//lcw
[
'name' => 'LCW',
'slug' => 'lcw',
'description' => 'LCW',
'meta_title' => '',
'meta_description' => '',
'meta_keywords' => '',
'category_id' => '2',
'locale' => 'en',
],
[
'name' => 'LCW',
'slug' => 'lcw',
'description' => 'LCW',
'meta_title' => '',
'meta_description' => '',
'meta_keywords' => '',
'category_id' => '2',
'locale' => 'ru',
],
[
'name' => 'LCW',
'slug' => 'lcw',
'description' => 'LCW',
'meta_title' => '',
'meta_description' => '',
'meta_keywords' => '',
'category_id' => '2',
'locale' => 'tm',
],
[
'name' => 'LCW',
'slug' => 'lcw',
'description' => 'LCW',
'meta_title' => '',
'meta_description' => '',
'meta_keywords' => '',
'category_id' => '2',
'locale' => 'tr',
],
//outlet
[
'name' => 'Outlet',
'slug' => 'outlet',
'description' => 'Outlet',
'meta_title' => '',
'meta_description' => '',
'meta_keywords' => '',
'category_id' => '3',
'locale' => 'en',
],
[
'name' => 'Outlet',
'slug' => 'outlet',
'description' => 'Outlet',
'meta_title' => '',
'meta_description' => '',
'meta_keywords' => '',
'category_id' => '3',
'locale' => 'ru',
],
[
'name' => 'Outlet',
'slug' => 'outlet',
'description' => 'Outlet',
'meta_title' => '',
'meta_description' => '',
'meta_keywords' => '',
'category_id' => '3',
'locale' => 'tm',
],
[
'name' => 'Outlet',
'slug' => 'outlet',
'description' => 'Outlet',
'meta_title' => '',
'meta_description' => '',
'meta_keywords' => '',
'category_id' => '3',
'locale' => 'tr',
]
]);
}
}

View File

@ -12,19 +12,39 @@ class ChannelTableSeeder extends Seeder
*/
public function run()
{
DB::table('channels')->delete();
DB::table('channels')->insert([
'id' => 2,
'code' => 'test',
'theme' => 'default',
'hostname' => config('app.url').'/test',
'root_category_id' => 2,
'default_locale_id' => 1,
'base_currency_id' => 1,
[
'id' => 1,
'code' => 'Trendyol',
'theme' => 'default',
'hostname' => config('app.url'),
'root_category_id' => 1,
'default_locale_id' => 1,
'base_currency_id' => 1
],[
'id' => 2,
'code' => 'LCW',
'theme' => 'default',
'hostname' => config('app.url').'/lcw',
'root_category_id' => 2,
'default_locale_id' => 1,
'base_currency_id' => 1
],[
'id' => 3,
'code' => 'Outlet',
'theme' => 'default',
'hostname' => config('app.url').'/outlet',
'root_category_id' => 3,
'default_locale_id' => 1,
'base_currency_id' => 1
],
]);
DB::table('channel_translations')->insert([
[
'id' => 6,
'channel_id' => 2,
'id' => 1,
'channel_id' => 1,
'locale' => 'en',
'name' => 'Test',
'home_page_content' => '
@ -63,10 +83,10 @@ class ChannelTableSeeder extends Seeder
',
'home_seo' => '{"meta_title": "Demo store", "meta_keywords": "Demo store meta keyword", "meta_description": "Demo store meta description"}',
], [
'id' => 7,
'channel_id' => 2,
'id' => 2,
'channel_id' => 1,
'locale' => 'tr',
'name' => 'Test',
'name' => 'Trendyol',
'home_page_content' => '
<p>@include("shop::home.slider") @include("shop::home.featured-products") @include("shop::home.new-products")</p>
<div class="banner-container">
@ -105,25 +125,57 @@ class ChannelTableSeeder extends Seeder
]
]);
DB::table('channel_currencies')->insert([[
DB::table('channel_currencies')->insert([
[
'channel_id' => 1,
'currency_id' => 1,
],
[
'channel_id' => 1,
'currency_id' => 2,
],
[
'channel_id' => 3,
'currency_id' => 1,
],
[
'channel_id' => 3,
'currency_id' => 2,
],
[
'channel_id' => 2,
'currency_id' => 3,
'currency_id' => 1,
],[
'channel_id' => 2,
'currency_id' => 4,
'currency_id' => 2,
]]);
DB::table('channel_locales')->insert([[
DB::table('channel_locales')->insert([
[
'channel_id' => 1,
'locale_id' => 1,
],
[
'channel_id' => 2,
'locale_id' => 6,
'locale_id' => 1,
],[
'channel_id' => 2,
'locale_id' => 7,
'channel_id' => 3,
'locale_id' => 1,
]]);
DB::table('channel_inventory_sources')->insert([
'channel_id' => 2,
'inventory_source_id' => 1,
[
'channel_id' => 1,
'inventory_source_id' => 1,
],
[
'channel_id' => 3,
'inventory_source_id' => 1,
],
[
'channel_id' => 2,
'inventory_source_id' => 1,
]
]);
}
}

View File

@ -0,0 +1,293 @@
<?php
namespace Sarga\Shop\Database\Seeders;
use Carbon\Carbon;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class ConfigTableSeeder extends Seeder
{
public function run()
{
DB::table('core_config')->delete();
$now = Carbon::now();
DB::table('core_config')->insert([
'id' => 1,
'code' => 'catalog.products.guest-checkout.allow-guest-checkout',
'value' => '0',
'channel_code' => null,
'locale_code' => null,
'created_at' => $now,
'updated_at' => $now,
]);
DB::table('core_config')->insert([
'id' => 2,
'code' => 'emails.general.notifications.emails.general.notifications.verification',
'value' => '1',
'channel_code' => null,
'locale_code' => null,
'created_at' => $now,
'updated_at' => $now,
]);
DB::table('core_config')->insert([
'id' => 3,
'code' => 'emails.general.notifications.emails.general.notifications.registration',
'value' => '1',
'channel_code' => null,
'locale_code' => null,
'created_at' => $now,
'updated_at' => $now,
]);
DB::table('core_config')->insert([
'id' => 4,
'code' => 'emails.general.notifications.emails.general.notifications.customer',
'value' => '1',
'channel_code' => null,
'locale_code' => null,
'created_at' => $now,
'updated_at' => $now,
]);
DB::table('core_config')->insert([
'id' => 5,
'code' => 'emails.general.notifications.emails.general.notifications.new-order',
'value' => '1',
'channel_code' => null,
'locale_code' => null,
'created_at' => $now,
'updated_at' => $now,
]);
DB::table('core_config')->insert([
'id' => 6,
'code' => 'emails.general.notifications.emails.general.notifications.new-admin',
'value' => '1',
'channel_code' => null,
'locale_code' => null,
'created_at' => $now,
'updated_at' => $now,
]);
DB::table('core_config')->insert([
'id' => 7,
'code' => 'emails.general.notifications.emails.general.notifications.new-invoice',
'value' => '1',
'channel_code' => null,
'locale_code' => null,
'created_at' => $now,
'updated_at' => $now,
]);
DB::table('core_config')->insert([
'id' => 8,
'code' => 'emails.general.notifications.emails.general.notifications.new-refund',
'value' => '1',
'channel_code' => null,
'locale_code' => null,
'created_at' => $now,
'updated_at' => $now,
]);
DB::table('core_config')->insert([
'id' => 9,
'code' => 'emails.general.notifications.emails.general.notifications.new-shipment',
'value' => '1',
'channel_code' => null,
'locale_code' => null,
'created_at' => $now,
'updated_at' => $now,
]);
DB::table('core_config')->insert([
'id' => 10,
'code' => 'emails.general.notifications.emails.general.notifications.new-inventory-source',
'value' => '1',
'channel_code' => null,
'locale_code' => null,
'created_at' => $now,
'updated_at' => $now,
]);
DB::table('core_config')->insert([
'id' => 11,
'code' => 'emails.general.notifications.emails.general.notifications.cancel-order',
'value' => '1',
'channel_code' => null,
'locale_code' => null,
'created_at' => $now,
'updated_at' => $now,
]);
DB::table('core_config')->insert([
'id' => 12,
'code' => 'catalog.products.homepage.out_of_stock_items',
'value' => '0',
'channel_code' => null,
'locale_code' => null,
'created_at' => $now,
'updated_at' => $now,
]);
DB::table('core_config')->insert([
[
'code' => 'general.content.shop.compare_option',
'value' => '0',
'channel_code' => 'default',
'locale_code' => 'en',
'created_at' => $now,
'updated_at' => $now,
],
[
'code' => 'general.content.shop.compare_option',
'value' => '0',
'channel_code' => 'default',
'locale_code' => 'tr',
'created_at' => $now,
'updated_at' => $now,
],
[
'code' => 'general.content.shop.compare_option',
'value' => '0',
'channel_code' => 'default',
'locale_code' => 'tm',
'created_at' => $now,
'updated_at' => $now,
],
[
'code' => 'general.content.shop.compare_option',
'value' => '0',
'channel_code' => 'default',
'locale_code' => 'ru',
'created_at' => $now,
'updated_at' => $now,
],
//Wishlist show config data
[
'code' => 'general.content.shop.wishlist_option',
'value' => '1',
'channel_code' => 'default',
'locale_code' => 'en',
'created_at' => $now,
'updated_at' => $now,
],
[
'code' => 'general.content.shop.wishlist_option',
'value' => '1',
'channel_code' => 'default',
'locale_code' => 'tr',
'created_at' => $now,
'updated_at' => $now,
],
[
'code' => 'general.content.shop.wishlist_option',
'value' => '1',
'channel_code' => 'default',
'locale_code' => 'tm',
'created_at' => $now,
'updated_at' => $now,
],
[
'code' => 'general.content.shop.wishlist_option',
'value' => '1',
'channel_code' => 'default',
'locale_code' => 'ru',
'created_at' => $now,
'updated_at' => $now,
],
/* Image search core config data starts here */
[
'code' => 'general.content.shop.image_search',
'value' => '0',
'channel_code' => 'default',
'locale_code' => 'en',
'created_at' => $now,
'updated_at' => $now,
],
[
'code' => 'general.content.shop.image_search',
'value' => '0',
'channel_code' => 'default',
'locale_code' => 'tr',
'created_at' => $now,
'updated_at' => $now,
],
[
'code' => 'general.content.shop.image_search',
'value' => '0',
'channel_code' => 'default',
'locale_code' => 'tm',
'created_at' => $now,
'updated_at' => $now,
],
[
'code' => 'general.content.shop.image_search',
'value' => '0',
'channel_code' => 'default',
'locale_code' => 'ru',
'created_at' => $now,
'updated_at' => $now,
],
]);
DB::table('core_config')->insert(
[
'code' => 'customer.settings.social_login.enable_facebook',
'value' => '0',
'channel_code' => 'default',
'locale_code' => null,
'created_at' => $now,
'updated_at' => $now,
]
);
DB::table('core_config')->insert(
[
'code' => 'customer.settings.social_login.enable_twitter',
'value' => '0',
'channel_code' => 'default',
'locale_code' => null,
'created_at' => $now,
'updated_at' => $now,
]
);
DB::table('core_config')->insert(
[
'code' => 'customer.settings.social_login.enable_google',
'value' => '0',
'channel_code' => 'default',
'locale_code' => null,
'created_at' => $now,
'updated_at' => $now,
]
);
DB::table('core_config')->insert(
[
'code' => 'customer.settings.social_login.enable_linkedin',
'value' => '0',
'channel_code' => 'default',
'locale_code' => null,
'created_at' => $now,
'updated_at' => $now,
]
);
DB::table('core_config')->insert(
[
'code' => 'customer.settings.social_login.enable_github',
'value' => '0',
'channel_code' => 'default',
'locale_code' => null,
'created_at' => $now,
'updated_at' => $now,
]
);
}
}

View File

@ -0,0 +1,18 @@
<?php
namespace Sarga\Shop\Database\Seeders;
use Illuminate\Support\Facades\DB;
use Illuminate\Database\Seeder;
class CountriesTableSeeder extends Seeder
{
public function run()
{
DB::table('countries')->delete();
$countries = json_decode(file_get_contents(__DIR__ . '/../../Data/countries.json'), true);
DB::table('countries')->insert($countries);
}
}

View File

@ -0,0 +1,33 @@
<?php
namespace Sarga\Shop\Database\Seeders;
use Illuminate\Support\Facades\DB;
use Illuminate\Database\Seeder;
use Illuminate\Support\Arr;
class CountryStateTranslationSeeder extends Seeder
{
public function run()
{
foreach (['ru', 'tm'] as $code) {
DB::table('country_translations')->where('locale', $code)->delete();
DB::table('country_state_translations')->where('locale', $code)->delete();
$countryTranslations = json_decode(file_get_contents(__DIR__ . '/../../Data/countries_' . $code . '.json'), true);
data_fill($countryTranslations, '*.locale', $code);
$stateTranslations = json_decode(file_get_contents(__DIR__ . '/../../Data/states_' . $code . '.json'), true);
data_fill($stateTranslations, '*.locale', $code);
DB::table('country_translations')->insert($countryTranslations);
DB::table('country_state_translations')->insert($stateTranslations);
}
}
}

View File

@ -16,6 +16,9 @@ class DatabaseSeeder extends Seeder
$this->call(SLocalesTableSeeder::class);
$this->call(SCurrencyTableSeeder::class);
$this->call(ChannelTableSeeder::class);
$this->call(CountriesTableSeeder::class);
$this->call(StatesTableSeeder::class);
$this->call(CountryStateTranslationSeeder::class);
}
}

View File

@ -8,17 +8,21 @@ use Illuminate\Support\Facades\DB;
class SCurrencyTableSeeder extends Seeder
{
public function run(){
DB::table('channels')->delete();
DB::table('currencies')->delete();
DB::table('currencies')->insert([
[
'id' => 3,
'id' => 1,
'code' => 'TL',
'name' => 'Lira',
'symbol' => 't',
'symbol' => 'TL',
], [
'id' => 4,
'id' => 2,
'code' => 'TMT',
'name' => 'Manat',
'symbol' => 'm',
'symbol' => 'TMT',
]
]);
}

View File

@ -8,16 +8,27 @@ use Illuminate\Support\Facades\DB;
class SLocalesTableSeeder extends Seeder
{
public function run(){
DB::table('locales')->insert([
DB::table('channels')->delete();
DB::table('locales')->delete();
DB::table('locales')->insert([
[
'id' => 6,
'code' => 'tm',
'id' => 1,
'code' => 'tr',
'name' => 'Türkçe',
], [
'id' => 2,
'code' => 'TM',
'name' => 'Türkmençe',
], [
'id' => 7,
'id' => 3,
'code' => 'ru',
'name' => 'Rusça',
'name' => 'Russian',
], [
'id' => 4,
'code' => 'en',
'name' => 'English',
]]);
}
}

View File

@ -0,0 +1,18 @@
<?php
namespace Sarga\Shop\Database\Seeders;
use Illuminate\Support\Facades\DB;
use Illuminate\Database\Seeder;
class StatesTableSeeder extends Seeder
{
public function run()
{
DB::table('country_states')->delete();
$states = json_decode(file_get_contents(__DIR__ . '/../../Data/states.json'), true);
DB::table('country_states')->insert($states);
}
}

View File

@ -65,7 +65,9 @@ class ShopServiceProvider extends ServiceProvider
view()->composer('shop::customers.account.partials.sidemenu', function ($view) {
$tree = Tree::create();
foreach (config('menu.customer') as $item) {
$menu = config('menu.customer');
foreach ($menu as $item) {
$tree->add($item, 'menu');
}

View File

@ -0,0 +1,37 @@
<?php
namespace Sarga\Shop\Repositories;
use Webkul\Category\Repositories\CategoryRepository as WCategoryRepository;
class CategoryRepository extends WCategoryRepository
{
public function getCategoryTree($id = null)
{
static $categories = [];
if (array_key_exists($id, $categories)) {
return $categories[$id];
}
return $categories[$id] = $id
? $this->model::orderBy('position', 'ASC')->descendantsAndSelf($id)->toTree($id)
: $this->model::orderBy('position', 'ASC')->get()->toTree();
}
public function getInvisibleCategories(){
return $this->getModel()
->whereNotNull('parent_id')
->where('status',0)
->get();
}
public function getDescriptionCategories(){
return $this->getModel()
->whereNotNull('parent_id')
->where('status',1)
->where('display_mode','description_only')
->get();
}
}

View File

@ -26,12 +26,14 @@ return [
'name' => 'shop::app.layouts.wishlist',
'route' =>'customer.wishlist.index',
'sort' => 4,
], [
'key' => 'account.compare',
'name' => 'shop::app.customer.compare.text',
'route' =>'velocity.customer.product.compare',
'sort' => 5,
], [
],
// [
// 'key' => 'account.compare',
// 'name' => 'shop::app.customer.compare.text',
// 'route' =>'velocity.customer.product.compare',
// 'sort' => 5,
// ],
[
'key' => 'account.orders',
'name' => 'shop::app.layouts.orders',
'route' =>'customer.orders.index',