vendor categories

This commit is contained in:
merdan 2022-11-18 12:01:21 +05:00
parent 2135fdbdcd
commit 6dc26409e8
7 changed files with 71 additions and 9 deletions

View File

@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class VendorCategoriesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('vendor_categories',function (Blueprint $table) {
$table->integer('vendor_id')->unsigned();
$table->integer('category_id')->unsigned();
$table->foreign('vendor_id')->references('id')->on('marketplace_sellers')->onDelete('cascade');
$table->foreign('category_id')->references('id')->on('categories')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('vendor_categories');
}
}

View File

@ -208,7 +208,7 @@ return [
'scrap' => [
'title' => 'Scrap',
'trendyol' => 'Trendyol',
]
],
],
'notification' => [
'notification-title' => 'Notification',

View File

@ -31,7 +31,6 @@
<accordian :title="'{{ __('admin::app.catalog.categories.general') }}'" :active="true">
<div slot="body">
{!! view_render_event('bagisto.admin.catalog.category.create_form_accordian.general.controls.before') !!}
<div class="control-group" :class="[errors.has('name') ? 'has-error' : '']">
<label for="name" class="required">{{ __('admin::app.catalog.categories.name') }}</label>
@ -62,7 +61,6 @@
<span class="control-error" v-if="errors.has('position')">@{{ errors.first('position') }}</span>
</div>
{!! view_render_event('bagisto.admin.catalog.category.create_form_accordian.general.controls.after') !!}
</div>
</accordian>
@ -71,7 +69,6 @@
<accordian :title="'{{ __('admin::app.catalog.categories.description-and-images') }}'" :active="true">
<div slot="body">
{!! view_render_event('bagisto.admin.catalog.category.create_form_accordian.description_images.controls.before') !!}
<div class="control-group" :class="[errors.has('display_mode') ? 'has-error' : '']">
<label for="display_mode" class="required">{{ __('admin::app.catalog.categories.display-mode') }}</label>
@ -106,7 +103,6 @@
</span>
</div>
{!! view_render_event('bagisto.admin.catalog.category.create_form_accordian.description_images.controls.after') !!}
</div>
</accordian>

View File

@ -25,5 +25,21 @@
<input type="text" v-validate="'required|numeric'" class="control" id="product_limit" name="product_limit" value="{{ old('product_limit',500)}}" data-vv-as="&quot;Products limit&quot;"/>
<span class="control-error" v-if="errors.has('product_limit')">@{{ errors.first('product_limit') }}</span>
</div>
<div class="control-group multi-select" :class="[errors.has('channels[]') ? 'has-error' : '']">
<label for="channels" class="required">Vendors</label>
<select class="control" name="vendors[]" v-validate="'required'" data-vv-as="&quot;Vendors&quot;" multiple>
@foreach (app('Sarga\Shop\Repositories\VendorRepository')->all() as $vendor)
<option value="{{ $vendor->id }}" >
{{ $vendor->shop_title }}
</option>
@endforeach
</select>
<span class="control-error" v-if="errors.has('vendors[]')">
@{{ errors.first('vendors[]') }}
</span>
</div>
</div>
</accordian>

View File

@ -27,6 +27,20 @@
value="{{ old('product_limit',$category->product_limit)}}" data-vv-as="&quot;Products limit&quot;"/>
<span class="control-error" v-if="errors.has('product_limit')">@{{ errors.first('product_limit') }}</span>
</div>
<div class="control-group multi-select" :class="[errors.has('channels[]') ? 'has-error' : '']">
<label for="channels" class="required">Vendors</label>
<?php $selectedaVendors = old('vendors') ?? $category->vendors->pluck('id')->toArray() ?>
<select class="control" name="vendors[]" v-validate="'required'" data-vv-as="&quot;Vendors&quot;" multiple>
@foreach (app('Sarga\Shop\Repositories\VendorRepository')->all() as $vendor)
<option value="{{ $vendor->id }}" {{ in_array($vendor->id, $selectedaVendors) ? 'selected' : ''}}>
{{ $vendor->shop_title }}
</option>
@endforeach
</select>
<span class="control-error" v-if="errors.has('vendors[]')">
@{{ errors.first('vendors[]') }}
</span>
</div>
</div>
</accordian>

View File

@ -54,4 +54,8 @@ class Category extends WCategory
public function brands() :BelongsToMany{
return $this->belongsToMany(BrandProxy::modelClass(),'category_brands');
}
public function vendors() :BelongsToMany{
return $this->belongsToMany(VendorProxy::modelClass(),'vendor_categories');
}
}

View File

@ -3,17 +3,16 @@
namespace Sarga\Shop\Models;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Sarga\Brand\Models\BrandProxy;
use Webkul\Category\Models\CategoryProxy;
use Webkul\Marketplace\Models\Seller;
use Webkul\Marketplace\Models\SellerCategoryProxy;
use Sarga\Shop\Contracts\Vendor as VendorContract;
class Vendor extends Seller implements VendorContract
{
public function categories() : HasOne
public function categories() : BelongsToMany
{
return $this->hasOne(SellerCategoryProxy::modelClass(),'seller_id',);
return $this->belongsToMany(CategoryProxy::modelClass(),'vendor_categories',);
}
public function brands() : BelongsToMany