admin menu filter and seller
This commit is contained in:
parent
bc69acaec7
commit
de321d9b5a
|
|
@ -55,6 +55,11 @@ class Vendors extends V1Controller
|
|||
return Source::collection($categorizedVendors);
|
||||
}
|
||||
|
||||
public function menus(MenuRepository $repository){
|
||||
$menus = $repository->where('status',1)->with(['categories','brands'])->orderBy('position','asc')->get();
|
||||
return Menu::collection($menus);
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$vendors = $this->vendorRepository->select('marketplace_sellers.id','url','logo','banner','shop_title','brand_attribute_id')
|
||||
|
|
|
|||
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace Sarga\API\Http\Resources\Catalog;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class Menu extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'name' => $this->name,
|
||||
'description' => $this->description,
|
||||
'categories' => Category::collection($this->categories),
|
||||
'brands' => Brands::collection($this->brands)
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateSellerMenusTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('menus', function (Blueprint $table) {
|
||||
$table->string('filter')->nullable();
|
||||
|
||||
});
|
||||
Schema::create('seller_menus',function (Blueprint $table) {
|
||||
$table->integer('menu_id')->unsigned();
|
||||
$table->integer('seller_id')->unsigned();
|
||||
$table->foreign('menu_id')->references('id')->on('menus');
|
||||
$table->foreign('seller_id')->references('id')->on('brands');
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('seller_menus');
|
||||
Schema::table('menus', function (Blueprint $table) {
|
||||
$table->dropColumn('filter');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -200,6 +200,7 @@ return [
|
|||
'brand-search-hint' => 'Brand search hint',
|
||||
'no-result-found' => 'No result found',
|
||||
'searching' => 'Searching',
|
||||
'sources' => 'Sources (Vendors)'
|
||||
],
|
||||
]
|
||||
];
|
||||
|
|
|
|||
|
|
@ -34,10 +34,16 @@
|
|||
|
||||
<div class="control-group" :class="[errors.has('name') ? 'has-error' : '']">
|
||||
<label for="name" class="required">{{ __('sarga::app.catalog.menus.name') }}</label>
|
||||
<input type="text" v-validate="'required'" class="control" id="name" name="name" value="{{ old('name') }}" data-vv-as=""{{ __('sarga::app.catalog.menus.name') }}"" v-slugify-target="'slug'"/>
|
||||
<input type="text" v-validate="'required'" class="control" id="name" name="name" value="{{ old('name') }}"
|
||||
data-vv-as=""{{ __('sarga::app.catalog.menus.name') }}"" />
|
||||
<span class="control-error" v-if="errors.has('name')">@{{ errors.first('name') }}</span>
|
||||
</div>
|
||||
|
||||
<div class="control-group" :class="[errors.has('filter') ? 'has-error' : '']">
|
||||
<label for="name" class="required">{{ __('sarga::app.catalog.menus.filter') }}</label>
|
||||
<input type="text" v-validate="'required'" class="control" id="filter" name="filter" value="{{ old('filter') }}"
|
||||
data-vv-as=""{{ __('sarga::app.catalog.menus.filter') }}"" />
|
||||
<span class="control-error" v-if="errors.has('filter')">@{{ errors.first('filter') }}</span>
|
||||
</div>
|
||||
<div class="control-group" :class="[errors.has('status') ? 'has-error' : '']">
|
||||
<label for="status" class="required">{{ __('sarga::app.catalog.menus.visible-in-menu') }}</label>
|
||||
<select class="control" v-validate="'required'" id="status" name="status" data-vv-as=""{{ __('sarga::app.catalog.menus.visible-in-menu') }}"">
|
||||
|
|
@ -67,7 +73,28 @@
|
|||
|
||||
</div>
|
||||
</accordian>
|
||||
<accordian title="{{ __('sarga::app.catalog.menus.sources') }}" :active="true">
|
||||
<div slot="body">
|
||||
<?php $selectedaSellers = old('sellers') ?: ['1'] ?>
|
||||
|
||||
<div class="control-group multi-select" :class="[errors.has('sellers[]') ? 'has-error' : '']">
|
||||
<label for="sellers" class="required">{{ __('sarga::app.catalog.menus.sources') }}</label>
|
||||
<select class="control" name="sellers[]" v-validate="'required'"
|
||||
data-vv-as=""{{ __('admin::app.catalog.menus.sources') }}"" multiple>
|
||||
|
||||
@foreach ($sellers as $seller)
|
||||
<option value="{{ $seller->id }}" {{ in_array($seller->id, $selectedaSellers) ? '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())
|
||||
|
||||
|
|
@ -79,6 +106,7 @@
|
|||
|
||||
@endif
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
|
|
|||
|
|
@ -62,11 +62,16 @@
|
|||
<label for="name" class="required">{{ __('sarga::app.catalog.menus.name') }}
|
||||
<span class="locale">[{{ $locale }}]</span>
|
||||
</label>
|
||||
<input type="text" v-validate="'required'" class="control" id="name" name="{{$locale}}[name]" value="{{ old($locale)['name'] ?? ($menu->translate($locale)['name'] ?? '') }}"
|
||||
<input type="text" v-validate="'required'" class="control" id="name" name="{{$locale}}[name]" value="{{ old($locale,$menu->translate($locale) )['name']) }}"
|
||||
data-vv-as=""{{ __('sarga::app.catalog.menus.name') }}"" />
|
||||
<span class="control-error" v-if="errors.has('{{$locale}}[name]')">@{{ errors.first('{!!$locale!!}[name]') }}</span>
|
||||
</div>
|
||||
|
||||
<div class="control-group" :class="[errors.has('filter') ? 'has-error' : '']">
|
||||
<label for="name" class="required">{{ __('sarga::app.catalog.menus.filter') }}</label>
|
||||
<input type="text" class="control" id="filter" name="filter" value="{{ old('filter',$menu->filter) }}"
|
||||
data-vv-as=""{{ __('sarga::app.catalog.menus.filter') }}"" />
|
||||
<span class="control-error" v-if="errors.has('filter')">@{{ errors.first('filter') }}</span>
|
||||
</div>
|
||||
<div class="control-group" :class="[errors.has('status') ? 'has-error' : '']">
|
||||
<label for="status" class="required">{{ __('sarga::app.catalog.menus.visible-in-menu') }}</label>
|
||||
<select class="control" v-validate="'required'" id="status" name="status" data-vv-as=""{{ __('sarga::app.catalog.menus.visible-in-menu') }}"">
|
||||
|
|
@ -96,7 +101,28 @@
|
|||
</div>
|
||||
</accordian>
|
||||
@include('sarga_admin::catalog.menus.menu-brand-links')
|
||||
<accordian title="{{ __('sarga::app.catalog.menus.sources') }}" :active="true">
|
||||
<div slot="body">
|
||||
<?php $selectedaSellers = old('sellers',$menu->sellers->pluck('id')->toArray()) ?>
|
||||
|
||||
<div class="control-group multi-select" :class="[errors.has('sellers[]') ? 'has-error' : '']">
|
||||
<label for="sellers" class="required">{{ __('sarga::app.catalog.menus.sources') }}</label>
|
||||
<select class="control" name="sellers[]" v-validate="'required'"
|
||||
data-vv-as=""{{ __('admin::app.catalog.menus.sources') }}"" multiple>
|
||||
|
||||
@foreach ($sellers as $seller)
|
||||
<option value="{{ $seller->id }}" {{ in_array($seller->id, $selectedaSellers) ? '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="{{ __('sarga::app.catalog.menus.categories') }}" :active="true">
|
||||
|
|
|
|||
|
|
@ -33,7 +33,8 @@ class Menu extends TranslatableModel implements MenuContract
|
|||
*/
|
||||
protected $with = ['translations'];
|
||||
|
||||
public function brands() :BelongsToMany{
|
||||
public function brands() :BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(BrandProxy::modelClass(),'menu_brands');
|
||||
}
|
||||
|
||||
|
|
@ -41,4 +42,9 @@ class Menu extends TranslatableModel implements MenuContract
|
|||
{
|
||||
return $this->belongsToMany(CategoryProxy::modelClass(), 'menu_categories');
|
||||
}
|
||||
|
||||
public function sellers():BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(VendorProxy::modelClass(),'seller_menus')
|
||||
}
|
||||
}
|
||||
|
|
@ -10,12 +10,18 @@ use Webkul\Marketplace\Models\SellerCategoryProxy;
|
|||
|
||||
class Vendor extends Seller
|
||||
{
|
||||
public function categories()
|
||||
public function categories() : HasOne
|
||||
{
|
||||
return $this->hasOne(SellerCategoryProxy::modelClass(),'seller_id',);
|
||||
}
|
||||
|
||||
public function brands(){
|
||||
public function brands() : BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(BrandProxy::modelClass(),'seller_brands','seller_id');
|
||||
}
|
||||
|
||||
public function menus() : BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(MenuProxy::modelClass(),'seller_menus','seller_id')
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace Sarga\Shop\Models;
|
||||
|
||||
class VendorProxy extends \Konekt\Concord\Proxies\ModelProxy
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -9,6 +9,7 @@ class ModuleServiceProvider extends CoreModuleServiceProvider
|
|||
protected $models = [
|
||||
\Sarga\Shop\Models\Recipient::class,
|
||||
\Sarga\Shop\Models\Menu::class,
|
||||
\Sarga\Shop\Models\Vendor::class,
|
||||
\Sarga\Shop\Models\MenuTranslation::class,
|
||||
];
|
||||
}
|
||||
|
|
@ -36,12 +36,14 @@ class MenuRepository extends Repository
|
|||
|
||||
$menu = $this->model->create($data);
|
||||
|
||||
// $this->uploadImages($data, $menu);
|
||||
// $product->categories()->sync($data['categories']);
|
||||
if (isset($data['categories'])) {
|
||||
$menu->categories()->sync($data['categories']);
|
||||
}
|
||||
|
||||
if(isset($data['sellers'])){
|
||||
$menu->sellers()->sync($data['sellers']);
|
||||
}
|
||||
|
||||
return $menu;
|
||||
}
|
||||
|
||||
|
|
@ -58,6 +60,10 @@ class MenuRepository extends Repository
|
|||
if (isset($data['brands'])) {
|
||||
$menu->brands()->sync($data['brands']);
|
||||
}
|
||||
|
||||
if(isset($data['sellers'])){
|
||||
$menu->sellers()->sync($data['sellers']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue