remove brand

This commit is contained in:
Kerim 2023-04-21 03:37:30 +05:00
parent a62c2b42e3
commit 9ad20050b1
33 changed files with 46 additions and 1014 deletions

View File

@ -281,7 +281,7 @@ return [
Webkul\DebugBar\Providers\DebugBarServiceProvider::class, Webkul\DebugBar\Providers\DebugBarServiceProvider::class,
Webkul\Marketing\Providers\MarketingServiceProvider::class, Webkul\Marketing\Providers\MarketingServiceProvider::class,
Webkul\Notification\Providers\NotificationServiceProvider::class, Webkul\Notification\Providers\NotificationServiceProvider::class,
// Webkul\Marketplace\Providers\MarketplaceServiceProvider::class, Webkul\Marketplace\Providers\MarketplaceServiceProvider::class,
Sarga\Shop\Providers\ShopServiceProvider::class, Sarga\Shop\Providers\ShopServiceProvider::class,
Sarga\API\Providers\APIServiceProvider::class, Sarga\API\Providers\APIServiceProvider::class,

View File

@ -25,10 +25,10 @@ class Brands extends \Webkul\RestApi\Http\Controllers\V1\Shop\ResourceController
* *
* @return string * @return string
*/ */
public function repository() // public function repository()
{ // {
return BrandRepository::class; // return BrandRepository::class;
} // }
/** /**
* Resource class name. * Resource class name.

View File

@ -8,7 +8,7 @@ use Sarga\API\Http\Resources\Catalog\HomeResource;
use Sarga\API\Http\Resources\Catalog\ProductVariant; use Sarga\API\Http\Resources\Catalog\ProductVariant;
use Sarga\API\Http\Resources\Catalog\Suggestion; use Sarga\API\Http\Resources\Catalog\Suggestion;
use Sarga\API\Http\Resources\Catalog\SuperAttribute; use Sarga\API\Http\Resources\Catalog\SuperAttribute;
use Sarga\Brand\Repositories\BrandRepository; // use Sarga\Brand\Repositories\BrandRepository;
use Sarga\Shop\Repositories\ProductRepository; use Sarga\Shop\Repositories\ProductRepository;
use Webkul\API\Http\Controllers\Shop\ProductController; use Webkul\API\Http\Controllers\Shop\ProductController;
use Sarga\API\Http\Resources\Catalog\Product as ProductResource; use Sarga\API\Http\Resources\Catalog\Product as ProductResource;

View File

@ -3,7 +3,7 @@
namespace Sarga\API\Http\Controllers; namespace Sarga\API\Http\Controllers;
use Sarga\API\Http\Resources\Catalog\Suggestion; use Sarga\API\Http\Resources\Catalog\Suggestion;
use Sarga\Brand\Repositories\BrandRepository; // use Sarga\Brand\Repositories\BrandRepository;
use Sarga\Shop\Repositories\CategoryRepository; use Sarga\Shop\Repositories\CategoryRepository;
use Webkul\Category\Models\CategoryTranslationProxy; use Webkul\Category\Models\CategoryTranslationProxy;
use Webkul\Product\Repositories\ProductFlatRepository; use Webkul\Product\Repositories\ProductFlatRepository;
@ -11,7 +11,7 @@ use Webkul\RestApi\Http\Controllers\V1\V1Controller;
class SearchController extends V1Controller class SearchController extends V1Controller
{ {
public function __construct(protected BrandRepository $brandRepository, public function __construct(
protected ProductFlatRepository $productFlatRepository, protected ProductFlatRepository $productFlatRepository,
protected CategoryRepository $categoryRepository) protected CategoryRepository $categoryRepository)
{ {

View File

@ -9,7 +9,7 @@ use Sarga\API\Http\Resources\Core\Vendor;
use Sarga\API\Http\Resources\Core\Review; use Sarga\API\Http\Resources\Core\Review;
use Sarga\API\Http\Resources\Core\VendorDetail; use Sarga\API\Http\Resources\Core\VendorDetail;
use Sarga\Shop\Repositories\ProductRepository; use Sarga\Shop\Repositories\ProductRepository;
use Sarga\Brand\Repositories\BrandRepository; // use Sarga\Brand\Repositories\BrandRepository;
use Sarga\Shop\Repositories\CategoryRepository; use Sarga\Shop\Repositories\CategoryRepository;
use Sarga\Shop\Models\Category; use Sarga\Shop\Models\Category;
use Webkul\Marketplace\Repositories\ReviewRepository; use Webkul\Marketplace\Repositories\ReviewRepository;
@ -72,7 +72,7 @@ class Vendors extends V1Controller
$item->review_average = $this->reviewRepository->getAverageRating($item); $item->review_average = $this->reviewRepository->getAverageRating($item);
return $item; return $item;
}); });
return Vendor::collection($reviewed_vendors); return Vendor::collection($reviewed_vendors);
} }
@ -104,7 +104,7 @@ class Vendors extends V1Controller
// dd($vendor->categories()->first()); // dd($vendor->categories()->first());
$vendor->review_average = $this->reviewRepository->getAverageRating($vendor); $vendor->review_average = $this->reviewRepository->getAverageRating($vendor);
// $vendor->reviews = $this->reviewRepository // $vendor->reviews = $this->reviewRepository
// ->where('marketplace_seller_id', $seller_id) // ->where('marketplace_seller_id', $seller_id)
// ->where('status', 'approved') // ->where('status', 'approved')
@ -118,8 +118,8 @@ class Vendors extends V1Controller
// return Review::collection($reviews); // return Review::collection($reviews);
// } // }
public function brands(BrandRepository $brandRepository, $seller_id){ // public function brands(BrandRepository $brandRepository, $seller_id){
return Brand::collection($brandRepository->findAllBySeller($seller_id)); // return Brand::collection($brandRepository->findAllBySeller($seller_id));
} // }
} }

View File

@ -50,12 +50,12 @@ class Product extends JsonResource
'in_stock' => $product->haveSufficientQuantity(1), 'in_stock' => $product->haveSufficientQuantity(1),
'is_wishlisted' => $this->isWishlisted($product) , 'is_wishlisted' => $this->isWishlisted($product) ,
'is_item_in_cart' => \Cart::hasProduct($product), 'is_item_in_cart' => \Cart::hasProduct($product),
'shop_title' => $this->shop_title, //'shop_title' => $this->shop_title,
'logo' => $this->logo ? Storage::url($this->logo) : null, //'logo' => $this->logo ? Storage::url($this->logo) : null,
'new' => $this->new, 'new' => $this->new,
'featured' => $this->featured, 'featured' => $this->featured,
// 'brand' => $product->brand->name ?? '', // 'brand' => $product->brand->name ?? '',
// 'show_quantity_changer' => $this->when( // 'show_quantity_changer' => $this->when(
// $product->type !== 'grouped', // $product->type !== 'grouped',

View File

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

View File

@ -1,4 +0,0 @@
<?php
return [
\Sarga\Brand\Providers\ModuleServiceProvider::class
];

View File

@ -1,11 +0,0 @@
<?php
return [
// [
// 'key' => 'catalog.brand',
// 'name' => 'brand::app.brands',
// 'route' => 'admin.catalog.brand.index',
// 'sort' => 5,
// 'icon-class' => '',
// ]
];

View File

@ -1,7 +0,0 @@
<?php
namespace Sarga\Brand\Contracts;
interface Brand
{
}

View File

@ -1,115 +0,0 @@
<?php namespace Sarga\Brand\DataGrids;
use Illuminate\Support\Facades\DB;
use Webkul\Ui\DataGrid\DataGrid;
class BrandDataGrid extends DataGrid
{
/**
* Index.
*
* @var string
*/
protected $index = 'id';
/**
* Sort order.
*
* @var string
*/
protected $sortOrder = 'desc';
public function prepareQueryBuilder()
{
$queryBuilder = DB::table('brands as br');
$this->addFilter('code', 'br.code');
$this->addFilter('name', 'br.name');
$this->addFilter('status', 'br.status');
$this->setQueryBuilder($queryBuilder);
}
public function addColumns()
{
$this->addColumn([
'index' => 'id',
'label' => trans('admin::app.datagrid.id'),
'type' => 'number',
'searchable' => false,
'sortable' => true,
'filterable' => true,
]);
$this->addColumn([
'index' => 'code',
'label' => trans('admin::app.datagrid.code'),
'type' => 'string',
'searchable' => true,
'sortable' => true,
'filterable' => true,
]);
$this->addColumn([
'index' => 'name',
'label' => trans('admin::app.datagrid.name'),
'type' => 'string',
'searchable' => true,
'sortable' => true,
'filterable' => true,
]);
$this->addColumn([
'index' => 'position',
'label' => trans('admin::app.datagrid.position'),
'type' => 'number',
'searchable' => false,
'sortable' => true,
'filterable' => true,
]);
$this->addColumn([
'index' => 'status',
'label' => trans('admin::app.datagrid.status'),
'type' => 'boolean',
'sortable' => true,
'searchable' => true,
'filterable' => true,
'closure' => function ($value) {
if ($value->status == 1) {
return trans('admin::app.datagrid.active');
} else {
return trans('admin::app.datagrid.inactive');
}
},
]);
}
/**
* Prepare actions.
*
* @return void
*/
public function prepareActions()
{
$this->addAction([
'title' => trans('admin::app.datagrid.edit'),
'method' => 'GET',
'route' => 'admin.catalog.brand.edit',
'icon' => 'icon pencil-lg-icon',
]);
$this->addAction([
'title' => trans('admin::app.datagrid.delete'),
'method' => 'POST',
'route' => 'admin.catalog.brand.delete',
'confirm_text' => trans('ui::app.datagrid.massaction.delete', ['resource' => 'brand']),
'icon' => 'icon trash-icon',
'function' => 'deleteCategory(event, "delete")'
]);
$this->addMassAction([
'type' => 'delete',
'label' => trans('admin::app.datagrid.delete'),
'action' => route('admin.catalog.brand.massdelete'),
'method' => 'POST',
]);
}
}

View File

@ -1,69 +0,0 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateBrandsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('brands', function (Blueprint $table) {
$table->increments('id');
$table->string('code')->unique();
$table->string('name');
$table->integer('position')->default(0);
$table->string('image')->nullable();
$table->boolean('status')->default(0);
$table->timestamps();
});
Schema::create('category_brands',function (Blueprint $table) {
$table->integer('category_id')->unsigned();
$table->integer('brand_id')->unsigned();
$table->foreign('category_id')->references('id')->on('categories')->onDelete('cascade');
$table->foreign('brand_id')->references('id')->on('brands')->onDelete('cascade');
});
// Schema::create('product_brands',function (Blueprint $table) {
// $table->integer('product_id')->unsigned();
// $table->integer('brand_id')->unsigned();
// $table->foreign('product_id')->references('id')->on('products')->onDelete('cascade');
// $table->foreign('brand_id')->references('id')->on('brands')->onDelete('cascade');
// });
Schema::table('products', function (Blueprint $table) {
$table->integer('brand_id')->unsigned()->nullable();
$table->foreign('brand_id')->references('id')->on('brands')->onDelete('set null');
});
Schema::create('seller_brands',function (Blueprint $table) {
$table->integer('seller_id')->unsigned();
$table->integer('brand_id')->unsigned();
$table->foreign('seller_id')->references('id')->on('marketplace_sellers')->onDelete('cascade');
$table->foreign('brand_id')->references('id')->on('brands')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('products', function (Blueprint $table) {
$table->dropColumn('brand_id');
});
Schema::dropIfExists('category_brands');
// Schema::dropIfExists('product_brands');
Schema::dropIfExists('seller_brands');
Schema::dropIfExists('brands');
}
}

View File

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

View File

@ -1,108 +0,0 @@
<?php namespace Sarga\Brand\Http\Controllers;
use Illuminate\Support\Facades\Event;
use Sarga\Brand\Repositories\BrandRepository;
use Sarga\Shop\Repositories\CategoryRepository;
use Webkul\Marketplace\Repositories\SellerRepository;
class BrandController extends Controller
{
/**
* Contains route related configuration.
*
* @var array
*/
protected $_config;
protected $brandRepository;
protected $sellerRepository;
protected $categoryRepository;
public function __construct(BrandRepository $brandRepository,
SellerRepository $sellerRepository,
CategoryRepository $categoryRepository)
{
$this->brandRepository = $brandRepository;
$this->sellerRepository = $sellerRepository;
$this->categoryRepository = $categoryRepository;
$this->_config = request('_config');
}
public function index() {
return view($this->_config['view']);
}
public function create(){
$sellers = $this->sellerRepository->findByField('is_approved',1);
$categories = $this->categoryRepository->getCategoryTree();
return view($this->_config['view'],compact('sellers','categories'));
}
public function store(){
$this->validate(request(), [
'code' => ['required', 'unique:brands,code', new \Webkul\Core\Contracts\Validations\Code],
'name' => 'required',
'position' => 'numeric',
'status' => 'numeric',
'image.*' => 'mimes:bmp,jpeg,jpg,png,webp',
]);
$this->brandRepository->create(request()->all());
session()->flash('success', trans('admin::app.response.create-success', ['name' => 'Brand']));
return redirect()->route($this->_config['redirect']);
}
public function edit($id){
$brand = $this->brandRepository->find($id);
$sellers = $this->sellerRepository->findByField('is_approved',1);
$categories = $this->categoryRepository->getCategoryTree();
return view($this->_config['view'], compact('brand','sellers','categories'));
}
public function update($id){
$this->validate(request(), [
'code' => ['required', 'unique:brands,code,'. $id, new \Webkul\Core\Contracts\Validations\Code],
'name' => 'required',
'position' => 'numeric',
'status' => 'numeric',
'image.*' => 'mimes:bmp,jpeg,jpg,png,webp',
]);
$this->brandRepository->update(request()->all(), $id);
session()->flash('success', trans('admin::app.response.update-success', ['name' => 'Brand']));
return redirect()->route($this->_config['redirect']);
}
public function destroy($id){
try {
$this->brandRepository->delete($id);
session()->flash('success', trans('admin::app.response.delete-success', ['name' => 'Brand']));
return response()->json(['message' => true], 200);
} catch (\Exception $e) {
session()->flash('error', trans('admin::app.response.delete-failed', ['name' => 'Brand']));
}
}
public function massDestroy(){
$brandIds = explode(',', request()->input('indexes'));
try {
$this->brandRepository->destroy($brandIds);
session()->flash('success', trans('admin::app.response.delete-success', ['name' => 'Brand']));
} catch (\Exception $e) {
session()->flash('error', trans('admin::app.response.delete-failed', ['name' => 'Brand']));
}
return redirect()->route($this->_config['redirect']);
}
}

View File

@ -1,13 +0,0 @@
<?php
namespace Sarga\Brand\Http\Controllers;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
class Controller extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
}

View File

@ -1,58 +0,0 @@
<?php namespace Sarga\Brand\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Support\Facades\Storage;
use Sarga\Brand\Contracts\Brand as BrandContract;
use Webkul\Category\Models\CategoryProxy;
use Webkul\Marketplace\Models\SellerProxy;
use Webkul\Product\Models\ProductProxy;
class Brand extends Model implements BrandContract
{
protected $fillable = [
'position',
'status',
'code',
'name'
];
/**
* Get image url for the category image.
*/
public function image_url()
{
if (! $this->image) {
return;
}
return Storage::url($this->image);
}
/**
* Get image url for the category image.
*/
public function getImageUrlAttribute()
{
return $this->image_url();
}
/**
* The products that belong to the category.
*/
public function products(): HasMany
{
return $this->hasMany(ProductProxy::modelClass(), 'brand_id');
}
public function sellers():BelongsToMany
{
return $this->belongsToMany(SellerProxy::modelClass(), 'seller_brands');
}
public function categories():BelongsToMany
{
return $this->belongsToMany(CategoryProxy::modelClass(), 'category_brands');
}
}

View File

@ -1,8 +0,0 @@
<?php
namespace Sarga\Brand\Models;
class BrandProxy extends \Konekt\Concord\Proxies\ModelProxy
{
}

View File

@ -1,36 +0,0 @@
<?php namespace Sarga\Brand\Providers;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\ServiceProvider;
class BrandServiceProvider extends ServiceProvider
{
/**
* Bootstrap services.
*
* @return void
*/
public function boot(): void
{
// $this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations');
// $this->loadRoutesFrom(__DIR__ . '/../Routes/brand-routes.php');
// $this->loadViewsFrom(__DIR__ . '/../Resources/views', 'brand');
// $this->loadTranslationsFrom(__DIR__ . '/../Resources/lang', 'brand');
// Log::info('brandd service provider');
$this->app->register(EventServiceProvider::class);
// CategoryProxy::observe(CategoryObserver::class);
}
public function register()
{
// $this->mergeConfigFrom(
// dirname(__DIR__) . '/Config/menu.php',
// 'menu.admin'
// );
// $this->mergeConfigFrom(
// dirname(__DIR__) . '/Config/concord.php',
// 'concord.modules'
// );
}
}

View File

@ -1,23 +0,0 @@
<?php
namespace Sarga\Brand\Providers;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\ServiceProvider;
class EventServiceProvider extends ServiceProvider
{
/**
* Bootstrap services.
*
* @return void
*/
public function boot(): void
{
Event::listen('bagisto.admin.catalog.product.edit_form_accordian.additional_views.before', function($viewRenderEventManager){
$viewRenderEventManager->addTemplate('brand::admin.catalog.products.fields.brand');
});
}
}

View File

@ -1,12 +0,0 @@
<?php
namespace Sarga\Brand\Providers;
use Webkul\Core\Providers\CoreModuleServiceProvider;
class ModuleServiceProvider extends CoreModuleServiceProvider
{
protected $models = [
\Sarga\Brand\Models\Brand::class,
];
}

View File

@ -1,98 +0,0 @@
<?php namespace Sarga\Brand\Repositories;
use Illuminate\Support\Facades\Storage;
use Webkul\Core\Eloquent\Repository;
class BrandRepository extends Repository
{
public function model()
{
return 'Sarga\Brand\Contracts\Brand';
}
public function create(array $data){
$brand = $this->model->create($data);
if(isset($data['sellers'])){
$brand->sellers()->sync($data['sellers']);
}
if(isset($data['categories'])){
$brand->categories()->sync($data['categories']);
}
$this->uploadImages($brand,$data);
return $brand;
}
public function update(array $data, $id){
$brand = $this->find($id);
$brand->update($data);
$this->uploadImages($brand, $data);
if(isset($data['sellers'])){
$brand->sellers()->sync($data['sellers']);
}
if(isset($data['categories'])){
$brand->categories()->sync($data['categories']);
}
return $brand;
}
public function uploadImages($brand,$data,$type = 'image') {
if (isset($data[$type])) {
$request = request();
foreach ($data[$type] as $imageId => $image) {
$file = $type . '.' . $imageId;
$dir = 'brand/' . $brand->id;
if ($request->hasFile($file)) {
if ($brand->{$type}) {
Storage::delete($brand->{$type});
}
$brand->{$type} = $request->file($file)->store($dir);
$brand->save();
}
}
} else {
if ($brand->{$type}) {
Storage::delete($brand->{$type});
}
$brand->{$type} = null;
$brand->save();
}
}
public function actives(){
return $this->findByField('status',1);
}
public function findAllBySeller($seller_id){
$query = $this->leftJoin('seller_brands as sb','sb.brand_id','=','brands.id')
->where('sb.seller_id',$seller_id);
if(request()->has('category_id')){
$query->leftJoin('category_brands as cb','cb.brand_id','=','brands.id')
->where('cb.category_id',request()->get('category_id'));
}
$limit = request()->get('limit') ?? 10;
$page = request()->get('page') ?? 1;
return $query->orderBy('position', 'ASC')
->skip(($page-1) * $limit)
->take($limit)
->get();
}
}

View File

@ -1,10 +0,0 @@
<?php
return [
'brand' => 'Brand',
'brands' => 'Brands',
'add_brand' => 'Add Brand',
'edit_brand' => 'Edit Brand',
'save_brand' => 'Save Brand',
'code' => 'Brand Code',
'name' => 'Brand Name',
];

View File

@ -1,10 +0,0 @@
<?php
return [
'brand' => 'Brand',
'brands' => 'Brands tt',
'add_brand' => 'Add Brand',
'edit_brand' => 'Edit Brand',
'save_brand' => 'Save Brand',
'code' => 'Brand Code',
'name' => 'Brand Name',
];

View File

@ -1,5 +0,0 @@
<?php
return[
'brand' => 'Marka',
'brands' => 'Markalar'
];

View File

@ -1,117 +0,0 @@
@extends('admin::layouts.content')
@section('page_title')
{{ __('brand::app.add_brand') }}
@stop
@section('content')
<div class="content">
<form method="POST" action="{{ route('admin.catalog.brand.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.catalog.brand.index') }}'"></i>
{{ __('brand::app.add_brand') }}
</h1>
</div>
<div class="page-action">
<button type="submit" class="btn btn-lg btn-primary">
{{ __('brand::app.save_brand') }}
</button>
</div>
</div>
<div class="page-content">
<div class="form-container">
@csrf()
<accordian :title="'{{ __('admin::app.catalog.attributes.general') }}'" :active="true">
<div slot="body">
<div class="control-group" :class="[errors.has('code') ? 'has-error' : '']">
<label for="code" class="required">{{ __('brand::app.code') }}</label>
<input type="text" v-validate="'required'" class="control" id="code" name="code" value="{{ old('code') }}"
data-vv-as="&quot;{{ __('brand::app.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">{{ __('brand::app.name') }}</label>
<input type="text" v-validate="'required'" class="control" id="name" name="name" value="{{ old('name') }}"
data-vv-as="&quot;{{ __('brand::app.name') }}&quot;" />
<span class="control-error" v-if="errors.has('name')">@{{ errors.first('name') }}</span>
</div>
<div class="control-group" :class="[errors.has('status') ? 'has-error' : '']">
<label for="status" class="required">{{ __('admin::app.catalog.categories.visible-in-menu') }}</label>
<select class="control" v-validate="'required'" id="status" name="status" data-vv-as="&quot;{{ __('admin::app.catalog.categories.visible-in-menu') }}&quot;">
<option value="1">
{{ __('admin::app.catalog.categories.yes') }}
</option>
<option value="0">
{{ __('admin::app.catalog.categories.no') }}
</option>
</select>
<span class="control-error" v-if="errors.has('status')">@{{ errors.first('status') }}</span>
</div>
<div class="control-group" :class="[errors.has('position') ? 'has-error' : '']">
<label for="position" class="required">{{ __('admin::app.catalog.categories.position') }}</label>
<input type="text" v-validate="'required|numeric'" class="control" id="position" name="position" value="{{ old('position') }}" data-vv-as="&quot;{{ __('admin::app.catalog.categories.position') }}&quot;"/>
<span class="control-error" v-if="errors.has('position')">@{{ errors.first('position') }}</span>
</div>
</div>
</accordian>
<accordian :title="'{{ __('admin::app.catalog.categories.description-and-images') }}'" :active="true">
<div slot="body">
<div class="control-group {!! $errors->has('image.*') ? 'has-error' : '' !!}">
<label>{{ __('admin::app.catalog.categories.image') }}</label>
<image-wrapper :button-label="'{{ __('admin::app.catalog.products.add-image-btn-title') }}'" input-name="image" :multiple="false"></image-wrapper>
<span class="control-error" v-if="{!! $errors->has('image.*') !!}">
@foreach ($errors->get('image.*') as $key => $message)
@php echo str_replace($key, 'Image', $message[0]); @endphp
@endforeach
</span>
</div>
{!! view_render_event('bagisto.admin.catalog.category.create_form_accordian.description_images.controls.after') !!}
</div>
</accordian>
<accordian :title="'{{ __('marketplace::app.admin.layouts.sellers') }}'" :active="true">
<div slot="body">
<div class="control-group" :class="[errors.has('sellers[]') ? 'has-error' : '']">
<label for="sellers" class="required">{{ __('marketplace::app.admin.layouts.sellers') }}</label>
<select class="control" name="sellers[]" v-validate="'required'" data-vv-as="&quot;{{ __('marketplace::app.admin.layouts.sellers') }}&quot;" multiple>
@foreach ($sellers as $seller)
<option value="{{ $seller->id }}" {{ old('sellers') && in_array($seller->id, old('sellers')) ? 'selected' : ''}}>
{{ $seller->shop_title}}
</option>
@endforeach
</select>
<span class="control-error" v-if="errors.has('sellers[]')">
@{{ errors.first('sellers[]') }}
</span>
</div>
</div>
</accordian>
@if ($categories->count())
<accordian :title="'{{ __('admin::app.catalog.products.categories') }}'" :active="false">
<div slot="body">
<tree-view behavior="normal" value-field="id" name-field="categories" input-type="checkbox" items='@json($categories)'
fallback-locale="{{ config('app.fallback_locale') }}">
</tree-view>
</div>
</accordian>
@endif
</div>
</div>
</form>
</div>
@stop

View File

@ -1,119 +0,0 @@
@extends('admin::layouts.content')
@section('page_title')
{{ __('brand::app.add_brand') }}
@stop
@section('content')
<div class="content">
<form method="POST" action="{{ route('admin.catalog.brand.update',['id'=>$brand->id]) }}" @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.catalog.brand.index') }}'"></i>
{{ __('brand::app.edit_brand') }}
</h1>
</div>
<div class="page-action">
<button type="submit" class="btn btn-lg btn-primary">
{{ __('brand::app.save_brand') }}
</button>
</div>
</div>
<div class="page-content">
<div class="form-container">
@csrf()
<accordian :title="'{{ __('admin::app.catalog.attributes.general') }}'" :active="true">
<div slot="body">
<div class="control-group" :class="[errors.has('code') ? 'has-error' : '']">
<label for="code" class="required">{{ __('brand::app.code') }}</label>
<input type="text" v-validate="'required'" class="control" id="code" name="code" value="{{ old('code',$brand->code) }}"
data-vv-as="&quot;{{ __('brand::app.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">{{ __('brand::app.name') }}</label>
<input type="text" v-validate="'required'" class="control" id="name" name="name" value="{{ old('name',$brand->name) }}"
data-vv-as="&quot;{{ __('brand::app.name') }}&quot;"/>
<span class="control-error" v-if="errors.has('name')">@{{ errors.first('name') }}</span>
</div>
<div class="control-group" :class="[errors.has('status') ? 'has-error' : '']">
<label for="status" class="required">{{ __('admin::app.catalog.categories.visible-in-menu') }}</label>
<select class="control" v-validate="'required'" id="status" name="status" data-vv-as="&quot;{{ __('admin::app.catalog.categories.visible-in-menu') }}&quot;">
<option value="1" @if($brand->status == 1)selected="selected" @endif >
{{ __('admin::app.catalog.categories.yes') }}
</option>
<option value="0" @if($brand->status == 0)selected="selected" @endif>
{{ __('admin::app.catalog.categories.no') }}
</option>
</select>
<span class="control-error" v-if="errors.has('status')">@{{ errors.first('status') }}</span>
</div>
<div class="control-group" :class="[errors.has('position') ? 'has-error' : '']">
<label for="position" class="required">{{ __('admin::app.catalog.categories.position') }}</label>
<input type="text" v-validate="'required|numeric'" class="control" id="position" name="position"
value="{{ old('position',$brand->position) }}" data-vv-as="&quot;{{ __('admin::app.catalog.categories.position') }}&quot;"/>
<span class="control-error" v-if="errors.has('position')">@{{ errors.first('position') }}</span>
</div>
</div>
</accordian>
<accordian :title="'{{ __('admin::app.catalog.categories.description-and-images') }}'" :active="true">
<div slot="body">
<div class="control-group {!! $errors->has('image.*') ? 'has-error' : '' !!}">
<label>{{ __('admin::app.catalog.categories.image') }}</label>
<image-wrapper :button-label="'{{ __('admin::app.catalog.products.add-image-btn-title') }}'"
:images='"{{ $brand->image_url }}"' input-name="image" :multiple="false"></image-wrapper>
<span class="control-error" v-if="{!! $errors->has('image.*') !!}">
@foreach ($errors->get('image.*') as $key => $message)
@php echo str_replace($key, 'Image', $message[0]); @endphp
@endforeach
</span>
</div>
{!! view_render_event('bagisto.admin.catalog.category.create_form_accordian.description_images.controls.after') !!}
</div>
</accordian>
<accordian :title="'{{ __('marketplace::app.admin.layouts.sellers') }}'" :active="true">
<div slot="body">
<div class="control-group" :class="[errors.has('sellers[]') ? 'has-error' : '']">
<label for="sellers" class="required">{{ __('marketplace::app.admin.layouts.sellers') }}</label>
<select class="control" name="sellers[]" v-validate="'required'" data-vv-as="&quot;{{ __('marketplace::app.admin.layouts.sellers') }}&quot;" multiple>
@php $selectedSellers = old('sellers',$brand->sellers->pluck('id')->toArray()) @endphp
@foreach ($sellers as $seller)
<option value="{{ $seller->id }}" {{ in_array($seller->id, $selectedSellers) ? 'selected' : ''}}>
{{ $seller->shop_title}}
</option>
@endforeach
</select>
<span class="control-error" v-if="errors.has('sellers[]')">
@{{ errors.first('sellers[]') }}
</span>
</div>
</div>
</accordian>
@if ($categories->count())
<accordian :title="'{{ __('admin::app.catalog.products.categories') }}'" :active="true">
<div slot="body">
<tree-view behavior="normal" value-field="id" name-field="categories" input-type="checkbox" items='@json($categories)'
value='@json($brand->categories->pluck("id"))' fallback-locale="{{ config('app.fallback_locale') }}">
</tree-view>
</div>
</accordian>
@endif
</div>
</div>
</form>
</div>
@stop

View File

@ -1,25 +0,0 @@
@extends('admin::layouts.content')
@section('page_title')
{{ __('brand::app.brands') }}
@stop
@section('content')
<div class="content">
<div class="page-header">
<div class="page-title">
<h1>{{ __('brand::app.brands') }}</h1>
</div>
<div class="page-action">
<a href="{{ route('admin.catalog.brand.create') }}" class="btn btn-lg btn-primary">
{{ __('brand::app.add_brand') }}
</a>
</div>
</div>
<div class="page-content">
{!! app('Sarga\Brand\DataGrids\BrandDataGrid')->render() !!}
</div>
</div>
@stop

View File

@ -1,15 +0,0 @@
@php $brands = app(Sarga\Brand\Repositories\BrandRepository::class)->actives(); @endphp
<div class="control-group" :class="[errors.has('brand_id') ? 'has-error' : '']">
<label for="brand_id" class="required">{{ __('brand::app.brand') }}</label>
<select class="control" v-validate="'required'" id="brand_id" name="brand_id" data-vv-as="&quot;{{ __('brand::app.brand') }}&quot;">
<option value="">Select</option>
@foreach($brands as $brand)
<option value="{{ $brand->id }}" {{ $product->brand_id == $brand->id ? 'selected' : '' }}>
{{ $brand->name }}
</option>
@endforeach
</select>
<span class="control-error" v-if="errors.has('brand_id')">@{{ errors.first('brand_id') }}</span>
</div>

View File

@ -1,44 +0,0 @@
<?php
use Illuminate\Support\Facades\Route;
use Sarga\Brand\Http\Controllers\BrandController;
/**
* Catalog routes.
*/
Route::group(['middleware' => ['web', 'admin', 'admin_locale'], 'prefix' => config('app.admin_url')], function () {
Route::prefix('catalog')->group(function () {
/**
* Categories routes.
*/
Route::get('/brands', [BrandController::class, 'index'])->defaults('_config', [
'view' => 'brand::admin.catalog.brand.index',
])->name('admin.catalog.brand.index');
Route::get('/brands/create', [BrandController::class, 'create'])->defaults('_config', [
'view' => 'brand::admin.catalog.brand.create',
])->name('admin.catalog.brand.create');
Route::post('/brands/create', [BrandController::class, 'store'])->defaults('_config', [
'redirect' => 'admin.catalog.brand.index',
])->name('admin.catalog.brand.store');
Route::get('/brands/edit/{id}', [BrandController::class, 'edit'])->defaults('_config', [
'view' => 'brand::admin.catalog.brand.edit',
])->name('admin.catalog.brand.edit');
Route::post('/brands/edit/{id}', [BrandController::class, 'update'])->defaults('_config', [
'redirect' => 'admin.catalog.brand.index',
])->name('admin.catalog.brand.update');
Route::post('/brands/delete/{id}', [BrandController::class, 'destroy'])
->name('admin.catalog.brand.delete');
Route::post('brands/massdelete', [BrandController::class, 'massDestroy'])->defaults('_config', [
'redirect' => 'admin.catalog.brand.index',
])->name('admin.catalog.brand.massdelete');
Route::post('/brands/product/count', [BrandController::class, 'productCount'])
->name('admin.catalog.brand.product.count');
});
});

View File

@ -1,9 +0,0 @@
<?php
/*
* Admin routes
*/
require 'admin-routes.php';
/*
* Shop routes
*/
require 'shop-routes.php';

View File

@ -1 +0,0 @@
<?php

View File

@ -9,7 +9,7 @@ use Illuminate\Support\Arr;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Event; use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Sarga\Brand\Repositories\BrandRepository; // use Sarga\Brand\Repositories\BrandRepository;
use Webkul\Attribute\Repositories\AttributeGroupRepository; use Webkul\Attribute\Repositories\AttributeGroupRepository;
use Webkul\Attribute\Repositories\AttributeOptionRepository; use Webkul\Attribute\Repositories\AttributeOptionRepository;
use Webkul\Attribute\Repositories\AttributeRepository; use Webkul\Attribute\Repositories\AttributeRepository;
@ -28,7 +28,7 @@ class ProductRepository extends WProductRepository
protected $attributeValueRepository; protected $attributeValueRepository;
protected $imageRepository; protected $imageRepository;
protected $vendorProductRepository; protected $vendorProductRepository;
protected $brandRepository; // protected $brandRepository;
protected $fillableTypes = ['sku', 'name', 'url_key', 'short_description', 'description', 'price', 'weight', 'status']; protected $fillableTypes = ['sku', 'name', 'url_key', 'short_description', 'description', 'price', 'weight', 'status'];
@ -40,7 +40,7 @@ class ProductRepository extends WProductRepository
ProductImageRepository $productImageRepository, ProductImageRepository $productImageRepository,
VendorProductRepository $vendorProductRepository, VendorProductRepository $vendorProductRepository,
VendorRepository $vendorRepository, VendorRepository $vendorRepository,
BrandRepository $brandRepository, // BrandRepository $brandRepository,
AttributeOptionRepository $optionRepository) AttributeOptionRepository $optionRepository)
{ {
$this->attributeGroupRepo = $attributeGroupRepo; $this->attributeGroupRepo = $attributeGroupRepo;
@ -49,8 +49,8 @@ class ProductRepository extends WProductRepository
$this->productFlatRepository = $productFlatRepository; $this->productFlatRepository = $productFlatRepository;
$this->imageRepository = $productImageRepository; $this->imageRepository = $productImageRepository;
$this->vendorProductRepository = $vendorProductRepository; $this->vendorProductRepository = $vendorProductRepository;
$this->brandRepository = $brandRepository; // $this->brandRepository = $brandRepository;
$this->vendorRepository = $vendorRepository; // $this->vendorRepository = $vendorRepository;
parent::__construct($attributeRepository, $app); parent::__construct($attributeRepository, $app);
} }
@ -294,9 +294,9 @@ class ProductRepository extends WProductRepository
} else } else
$product['attribute_family_id'] = $product['type'] == 'configurable' ? 2 : 1; $product['attribute_family_id'] = $product['type'] == 'configurable' ? 2 : 1;
if(!empty($data['brand']) && $brand = $this->brandRepository->findOneByField('name' , $data['brand'])){ // if(!empty($data['brand']) && $brand = $this->brandRepository->findOneByField('name' , $data['brand'])){
$product['brand_id'] = $brand->id; // $product['brand_id'] = $brand->id;
} // }
//create product //create product
$parentProduct = $this->getModel()->create($product); $parentProduct = $this->getModel()->create($product);
$this->assignAttributes($parentProduct, [ $this->assignAttributes($parentProduct, [

View File

@ -1,25 +1,25 @@
<?php <?php
return [ return [
[ // [
'key' => 'marketplace', // 'key' => 'marketplace',
'name' => 'marketplace::app.admin.acl.marketplace', // 'name' => 'marketplace::app.admin.acl.marketplace',
'route' => 'admin.marketplace.sellers.index', // 'route' => 'admin.marketplace.sellers.index',
'sort' => 2 // 'sort' => 2
], [ // ], [
'key' => 'marketplace.sellers', // 'key' => 'marketplace.sellers',
'name' => 'marketplace::app.admin.acl.sellers', // 'name' => 'marketplace::app.admin.acl.sellers',
'route' => 'admin.marketplace.sellers.index', // 'route' => 'admin.marketplace.sellers.index',
'sort' => 1 // 'sort' => 1
], [ // ], [
'key' => 'marketplace.products', // 'key' => 'marketplace.products',
'name' => 'marketplace::app.admin.acl.products', // 'name' => 'marketplace::app.admin.acl.products',
'route' => 'admin.marketplace.products.index', // 'route' => 'admin.marketplace.products.index',
'sort' => 2 // 'sort' => 2
], [ // ], [
'key' => 'marketplace.reviews', // 'key' => 'marketplace.reviews',
'name' => 'marketplace::app.admin.acl.reviews', // 'name' => 'marketplace::app.admin.acl.reviews',
'route' => 'admin.marketplace.reviews.index', // 'route' => 'admin.marketplace.reviews.index',
'sort' => 3 // 'sort' => 3
] // ]
]; ];