Merge branch 'development' of https://github.com/prashant-webkul/bagisto into development
This commit is contained in:
commit
0ce6348de6
|
|
@ -17,6 +17,6 @@ return [
|
|||
\Webkul\Inventory\Providers\ModuleServiceProvider::class,
|
||||
\Webkul\Product\Providers\ModuleServiceProvider::class,\Webkul\Sales\Providers\ModuleServiceProvider::class,
|
||||
\Webkul\Tax\Providers\ModuleServiceProvider::class,
|
||||
\Webkul\User\Providers\ModuleServiceProvider::class
|
||||
\Webkul\User\Providers\ModuleServiceProvider::class,\Webkul\Discount\Providers\ModuleServiceProvider::class
|
||||
]
|
||||
];
|
||||
|
|
@ -1,12 +1,12 @@
|
|||
@extends('admin::layouts.content')
|
||||
|
||||
@section('page_title')
|
||||
{{ __('admin::app.promotion.add-cart-rule') }}
|
||||
{{ __('admin::app.promotion.add-catalog-rule') }}
|
||||
@stop
|
||||
|
||||
@section('content')
|
||||
<div class="content">
|
||||
<form method="POST" action="{{ route('admin.cart-rule.store') }}" @submit.prevent="onSubmit">
|
||||
<form method="POST" action="{{ route('admin.catalog-rule.store') }}" @submit.prevent="onSubmit">
|
||||
@csrf
|
||||
|
||||
<div class="page-header">
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
<h1>
|
||||
<i class="icon angle-left-icon back-link" onclick="history.length > 1 ? history.go(-1) : window.location = '{{ url('/admin/dashboard') }}';"></i>
|
||||
|
||||
{{ __('admin::app.promotion.add-cart-rule') }}
|
||||
{{ __('admin::app.promotion.add-catalog-rule') }}
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
|
|
@ -27,14 +27,14 @@
|
|||
|
||||
<div class="page-content">
|
||||
<div class="form-container">
|
||||
<cart-rule></cart-rule>
|
||||
<catalog-rule></catalog-rule>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@push('scripts')
|
||||
<script type="text/x-template" id="cart-rule-form-template">
|
||||
<script type="text/x-template" id="catalog-rule-form-template">
|
||||
<div>
|
||||
@csrf()
|
||||
|
||||
|
|
@ -43,7 +43,7 @@
|
|||
<div class="control-group" :class="[errors.has('name') ? 'has-error' : '']">
|
||||
<label for="name" class="required">{{ __('admin::app.promotion.general-info.name') }}</label>
|
||||
|
||||
<input type="text" class="control" name="name" v-model="name" v-validate="'required'" value="{{ old('name') }}" data-vv-as=""{{ __('admin::app.promotion.general-info.firstname') }}"">
|
||||
<input type="text" class="control" name="name" v-model="name" v-validate="'required'" value="{{ old('name') }}" data-vv-as=""{{ __('admin::app.promotion.general-info.name') }}"">
|
||||
<span class="control-error" v-if="errors.has('name')">@{{ errors.first('name') }}</span>
|
||||
</div>
|
||||
|
||||
|
|
@ -67,7 +67,7 @@
|
|||
<span class="control-error" v-if="errors.has('customer_groups[]')">@{{ errors.first('customer_groups') }}</span>
|
||||
</div>
|
||||
|
||||
<div class="control-group" :class="[errors.has('channels') ? 'has-error' : '']">
|
||||
<div class="control-group" :class="[errors.has('channels[]') ? 'has-error' : '']">
|
||||
<label for="channels" class="required">{{ __('admin::app.promotion.general-info.channels') }}</label>
|
||||
<select type="text" class="control" name="channels[]" v-model="channels" v-validate="'required'" value="{{ old('channels') }}" data-vv-as=""{{ __('admin::app.promotion.general-info.cust-groups') }}"" multiple="multiple">
|
||||
<option disabled="disabled">Select Channels</option>
|
||||
|
|
@ -75,24 +75,34 @@
|
|||
<option value="{{ $channel->id }}">{{ $channel->name }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
<span class="control-error" v-if="errors.has('channels')">@{{ errors.first('channels') }}</span>
|
||||
<span class="control-error" v-if="errors.has('channels[]')">@{{ errors.first('channels') }}</span>
|
||||
</div>
|
||||
|
||||
<div class="control-group" :class="[errors.has('starts_from') ? 'has-error' : '']">
|
||||
<label for="starts_from" class="required">{{ __('admin::app.promotion.general-info.starts-from') }}</label>
|
||||
<input type="text" class="control" name="starts_from" v-model="starts_from" v-validate="'required'" value="{{ old('starts_from') }}" data-vv-as=""{{ __('admin::app.promotion.general-info.starts-from') }}"">
|
||||
<span class="control-error" v-if="errors.has('starts_from')">@{{ errors.first('starts_from') }}</span>
|
||||
</div>
|
||||
<datetime :name="starts_from">
|
||||
<div class="control-group" :class="[errors.has('starts_from') ? 'has-error' : '']">
|
||||
<label for="starts_from" class="required">{{ __('admin::app.promotion.general-info.starts-from') }}</label>
|
||||
|
||||
<div class="control-group" :class="[errors.has('ends_till') ? 'has-error' : '']">
|
||||
<label for="ends_till" class="required">{{ __('admin::app.promotion.general-info.ends-till') }}</label>
|
||||
<input type="text" class="control" name="ends_till" v-model="ends_till" v-validate="'required'" value="{{ old('ends_till') }}" data-vv-as=""{{ __('admin::app.promotion.general-info.ends_till') }}"">
|
||||
<span class="control-error" v-if="errors.has('ends_till')">@{{ errors.first('ends_till') }}</span>
|
||||
</div>
|
||||
<input type="text" class="control" v-model="starts_from" name="starts_from" v-validate="'required'" data-vv-as=""{{ __('admin::app.promotion.general-info.starts-from') }}"">
|
||||
|
||||
<span class="control-error" v-if="errors.has('starts_from')">@{{ errors.first('starts_from') }}</span>
|
||||
</div>
|
||||
</datetime>
|
||||
|
||||
<datetime :name="starts_from">
|
||||
<div class="control-group" :class="[errors.has('ends_till') ? 'has-error' : '']">
|
||||
<label for="ends_till" class="required">{{ __('admin::app.promotion.general-info.ends-till') }}</label>
|
||||
|
||||
<input type="text" class="control" v-model="ends_till" name="ends_till" v-validate="'required'" data-vv-as=""{{ __('admin::app.promotion.general-info.ends-till') }}"">
|
||||
|
||||
<span class="control-error" v-if="errors.has('ends_till')">@{{ errors.first('ends_till') }}</span>
|
||||
</div>
|
||||
</datetime>
|
||||
|
||||
<div class="control-group" :class="[errors.has('priority') ? 'has-error' : '']">
|
||||
<label for="priority" class="required">{{ __('admin::app.promotion.general-info.priority') }}</label>
|
||||
|
||||
<input type="text" class="control" name="priority" v-model="priority" v-validate="'required|numeric|max:1'" value="{{ old('priority') }}" data-vv-as=""{{ __('admin::app.promotion.general-info.priority') }}"">
|
||||
|
||||
<span class="control-error" v-if="errors.has('priority')">@{{ errors.first('priority') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -171,25 +181,25 @@
|
|||
<div class="control-group" :class="[errors.has('apply') ? 'has-error' : '']">
|
||||
<label for="apply" class="required">Apply</label>
|
||||
|
||||
<select class="control" name="apply" v-model="apply" v-validate="'required'" value="{{ old('apply') }}" data-vv-as=""Apply As"">
|
||||
<option value="1">Apply as percentage</option>
|
||||
<option value="2">Apply as fixed Amount</option>
|
||||
<option value="3">Adjust to percentage's value</option>
|
||||
<option value="4">Adjust to discount value</option>
|
||||
<select class="control" name="apply" v-model="apply" v-validate="'required'" value="{{ old('apply') }}" data-vv-as=""Apply As"" v-on:change="detectApply">
|
||||
<option value="1">{{ __('admin::app.promotion.catalog.apply-percent') }}</option>
|
||||
<option value="2">{{ __('admin::app.promotion.catalog.apply-fixed') }}</option>
|
||||
<option value="3">{{ __('admin::app.promotion.catalog.adjust-to-percent') }}</option>
|
||||
<option value="4">{{ __('admin::app.promotion.catalog.adjust-to-value') }}</option>
|
||||
</select>
|
||||
|
||||
<span class="control-error" v-if="errors.has('apply')">@{{ errors.first('apply') }}</span>
|
||||
</div>
|
||||
|
||||
<div class="control-group" :class="[errors.has('disc_amt') ? 'has-error' : '']">
|
||||
<div class="control-group" :class="[errors.has('disc_amt') ? 'has-error' : '']" v-if="apply_amt">
|
||||
<label for="disc_amt" class="required">{{ __('admin::app.promotion.general-info.disc_amt') }}</label>
|
||||
<input type="text" class="control" name="disc_amt" v-model="disc_amt" v-validate="'required|numeric|max:1'" value="{{ old('disc_amt') }}" data-vv-as=""{{ __('admin::app.promotion.general-info.disc_amt') }}"">
|
||||
<input type="text" class="control" name="disc_amt" v-model="disc_amt" v-validate="'required|numeric'" value="{{ old('disc_amt') }}" data-vv-as=""{{ __('admin::app.promotion.general-info.disc_amt') }}"">
|
||||
<span class="control-error" v-if="errors.has('disc_amt')">@{{ errors.first('disc_amt') }}</span>
|
||||
</div>
|
||||
|
||||
<div class="control-group" :class="[errors.has('disc_percent') ? 'has-error' : '']">
|
||||
<div class="control-group" :class="[errors.has('disc_percent') ? 'has-error' : '']" v-if="apply_prct">
|
||||
<label for="disc_percent" class="required">{{ __('admin::app.promotion.general-info.disc_percent') }}</label>
|
||||
<input type="text" class="control" name="disc_percent" v-model="disc_percent" v-validate="'required|numeric|max:1'" value="{{ old('disc_percent') }}" data-vv-as=""{{ __('admin::app.promotion.general-info.disc_percent') }}"">
|
||||
<input type="text" class="control" name="disc_percent" v-model="disc_percent" v-validate="'required|numeric'" value="{{ old('disc_percent') }}" data-vv-as=""{{ __('admin::app.promotion.general-info.disc_percent') }}"">
|
||||
<span class="control-error" v-if="errors.has('disc_percent')">@{{ errors.first('disc_percent') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -198,37 +208,43 @@
|
|||
</script>
|
||||
|
||||
<script>
|
||||
Vue.component('cart-rule', {
|
||||
template: '#cart-rule-form-template',
|
||||
Vue.component('catalog-rule', {
|
||||
template: '#catalog-rule-form-template',
|
||||
|
||||
inject: ['$validator'],
|
||||
|
||||
data () {
|
||||
return {
|
||||
apply: null,
|
||||
apply_amt: false,
|
||||
apply_prct: false,
|
||||
attributes: @json($criteria[0]),
|
||||
categories: @json($criteria[1]),
|
||||
channels: [],
|
||||
conditions: [],
|
||||
attrs_count: 0,
|
||||
cats_count: 0,
|
||||
name: '10% OFF',
|
||||
priority: 1,
|
||||
starts_from: 'a',
|
||||
ends_till: 'b',
|
||||
description: 'something',
|
||||
customer_groups: [],
|
||||
criteria: null,
|
||||
attr: {
|
||||
attribute: null,
|
||||
condition: null,
|
||||
value: null
|
||||
},
|
||||
attrs: [],
|
||||
attrs_count: 0,
|
||||
cat: {
|
||||
category: null,
|
||||
condition: null,
|
||||
},
|
||||
attrs: [],
|
||||
cats: []
|
||||
categories: @json($criteria[1]),
|
||||
cats: [],
|
||||
cats_count: 0,
|
||||
channels: [],
|
||||
conditions: [],
|
||||
criteria: null,
|
||||
customer_groups: [],
|
||||
description: null,
|
||||
disc_amount: 0.0,
|
||||
disc_percent: 0.0,
|
||||
ends_till: null,
|
||||
end_other_rules: null,
|
||||
name: null,
|
||||
priority: 0,
|
||||
starts_from: null
|
||||
}
|
||||
},
|
||||
|
||||
|
|
@ -263,6 +279,16 @@
|
|||
}
|
||||
},
|
||||
|
||||
detectApply() {
|
||||
if (this.apply == 1 || this.apply == 3) {
|
||||
this.apply_prct = true;
|
||||
this.apply_amt = false;
|
||||
} else if (this.apply == 2 || this.apply == 4) {
|
||||
this.apply_prct = false;
|
||||
this.apply_amt = true;
|
||||
}
|
||||
},
|
||||
|
||||
removeAttr(index) {
|
||||
this.attrs.splice(index, 1);
|
||||
},
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@
|
|||
<div class="control-group" :class="[errors.has('name') ? 'has-error' : '']">
|
||||
<label for="name" class="required">{{ __('admin::app.promotion.general-info.name') }}</label>
|
||||
|
||||
<input type="text" class="control" name="name" v-model="name" v-validate="'required'" value="{{ old('name') }}" data-vv-as=""{{ __('admin::app.promotion.general-info.firstname') }}"">
|
||||
<input type="text" class="control" name="name" v-model="name" v-validate="'required'" value="{{ old('name') }}" data-vv-as=""{{ __('admin::app.promotion.general-info.name') }}"">
|
||||
<span class="control-error" v-if="errors.has('name')">@{{ errors.first('name') }}</span>
|
||||
</div>
|
||||
|
||||
|
|
@ -67,7 +67,7 @@
|
|||
<span class="control-error" v-if="errors.has('customer_groups[]')">@{{ errors.first('customer_groups') }}</span>
|
||||
</div>
|
||||
|
||||
<div class="control-group" :class="[errors.has('channels') ? 'has-error' : '']">
|
||||
<div class="control-group" :class="[errors.has('channels[]') ? 'has-error' : '']">
|
||||
<label for="channels" class="required">{{ __('admin::app.promotion.general-info.channels') }}</label>
|
||||
<select type="text" class="control" name="channels[]" v-model="channels" v-validate="'required'" value="{{ old('channels') }}" data-vv-as=""{{ __('admin::app.promotion.general-info.cust-groups') }}"" multiple="multiple">
|
||||
<option disabled="disabled">Select Channels</option>
|
||||
|
|
@ -75,44 +75,34 @@
|
|||
<option value="{{ $channel->id }}">{{ $channel->name }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
<span class="control-error" v-if="errors.has('channels')">@{{ errors.first('channels') }}</span>
|
||||
<span class="control-error" v-if="errors.has('channels[]')">@{{ errors.first('channels') }}</span>
|
||||
</div>
|
||||
|
||||
<datetime :name="starts_from">
|
||||
<label for="starts_from" class="required">{{ __('admin::app.promotion.general-info.starts-from') }}</label>
|
||||
<div class="control-group" :class="[errors.has('starts_from') ? 'has-error' : '']">
|
||||
<label for="starts_from" class="required">{{ __('admin::app.promotion.general-info.starts-from') }}</label>
|
||||
|
||||
<div class="control-group">
|
||||
<input type="text" class="control" name="starts_from" v-validate="'required'" data-vv-as=""{{ __('admin::app.promotion.general-info.starts-from') }}"">
|
||||
<input type="text" class="control" v-model="starts_from" name="starts_from" v-validate="'required'" data-vv-as=""{{ __('admin::app.promotion.general-info.starts-from') }}"">
|
||||
|
||||
<span class="control-error" v-if="errors.has('starts_from')">@{{ errors.first('starts_from') }}</span>
|
||||
</div>
|
||||
|
||||
<span class="control-error" v-if="errors.has('starts_from')">@{{ errors.first('starts_from') }}</span>
|
||||
</datetime>
|
||||
|
||||
<datetime :name="starts_from">
|
||||
<div class="control-group">
|
||||
<div class="control-group" :class="[errors.has('ends_till') ? 'has-error' : '']">
|
||||
<label for="ends_till" class="required">{{ __('admin::app.promotion.general-info.ends-till') }}</label>
|
||||
|
||||
<input type="text" class="control" name="ends_till" v-validate="'required'" data-vv-as=""{{ __('admin::app.promotion.general-info.ends_till') }}"">
|
||||
<input type="text" class="control" v-model="ends_till" name="ends_till" v-validate="'required'" data-vv-as=""{{ __('admin::app.promotion.general-info.ends-till') }}"">
|
||||
|
||||
<span class="control-error" v-if="errors.has('ends_till')">@{{ errors.first('ends_till') }}</span>
|
||||
</div>
|
||||
</datetime>
|
||||
|
||||
{{-- <div class="control-group" :class="[errors.has('starts_from') ? 'has-error' : '']">
|
||||
<label for="starts_from" class="required">{{ __('admin::app.promotion.general-info.starts-from') }}</label>
|
||||
<input type="datetime" class="control" name="starts_from" v-model="starts_from" v-validate="'required'" value="{{ old('starts_from') }}" data-vv-as=""{{ __('admin::app.promotion.general-info.starts-from') }}"">
|
||||
<span class="control-error" v-if="errors.has('starts_from')">@{{ errors.first('starts_from') }}</span>
|
||||
</div>
|
||||
|
||||
<div class="control-group" :class="[errors.has('ends_till') ? 'has-error' : '']">
|
||||
<label for="ends_till" class="required">{{ __('admin::app.promotion.general-info.ends-till') }}</label>
|
||||
<input type="datetime" class="control" name="ends_till" v-model="ends_till" v-validate="'required'" value="{{ old('ends_till') }}" data-vv-as=""{{ __('admin::app.promotion.general-info.ends_till') }}"">
|
||||
<span class="control-error" v-if="errors.has('ends_till')">@{{ errors.first('ends_till') }}</span>
|
||||
</div> --}}
|
||||
|
||||
<div class="control-group" :class="[errors.has('priority') ? 'has-error' : '']">
|
||||
<label for="priority" class="required">{{ __('admin::app.promotion.general-info.priority') }}</label>
|
||||
|
||||
<input type="text" class="control" name="priority" v-model="priority" v-validate="'required|numeric|max:1'" value="{{ old('priority') }}" data-vv-as=""{{ __('admin::app.promotion.general-info.priority') }}"">
|
||||
|
||||
<span class="control-error" v-if="errors.has('priority')">@{{ errors.first('priority') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -209,7 +199,7 @@
|
|||
|
||||
<div class="control-group" :class="[errors.has('disc_percent') ? 'has-error' : '']" v-if="apply_prct">
|
||||
<label for="disc_percent" class="required">{{ __('admin::app.promotion.general-info.disc_percent') }}</label>
|
||||
<input type="text" class="control" name="disc_percent" v-model="disc_percent" v-validate="'required|numeric|max:2'" value="{{ old('disc_percent') }}" data-vv-as=""{{ __('admin::app.promotion.general-info.disc_percent') }}"">
|
||||
<input type="text" class="control" name="disc_percent" v-model="disc_percent" v-validate="'required|numeric'" value="{{ old('disc_percent') }}" data-vv-as=""{{ __('admin::app.promotion.general-info.disc_percent') }}"">
|
||||
<span class="control-error" v-if="errors.has('disc_percent')">@{{ errors.first('disc_percent') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -225,34 +215,36 @@
|
|||
|
||||
data () {
|
||||
return {
|
||||
attributes: @json($criteria[0]),
|
||||
categories: @json($criteria[1]),
|
||||
channels: [],
|
||||
conditions: [],
|
||||
attrs_count: 0,
|
||||
cats_count: 0,
|
||||
name: '10% OFF',
|
||||
priority: 1,
|
||||
starts_from: null,
|
||||
ends_till: null,
|
||||
description: 'something',
|
||||
customer_groups: [],
|
||||
criteria: null,
|
||||
apply: null,
|
||||
apply_amt: false,
|
||||
apply_prct: false,
|
||||
end_other_rules: null,
|
||||
attributes: @json($criteria[0]),
|
||||
attr: {
|
||||
attribute: null,
|
||||
condition: null,
|
||||
value: null
|
||||
},
|
||||
attrs: [],
|
||||
attrs_count: 0,
|
||||
cat: {
|
||||
category: null,
|
||||
condition: null,
|
||||
},
|
||||
attrs: [],
|
||||
cats: []
|
||||
categories: @json($criteria[1]),
|
||||
cats: [],
|
||||
cats_count: 0,
|
||||
channels: [],
|
||||
conditions: [],
|
||||
criteria: null,
|
||||
customer_groups: [],
|
||||
description: null,
|
||||
disc_amount: 0.0,
|
||||
disc_percent: 0.0,
|
||||
ends_till: null,
|
||||
end_other_rules: null,
|
||||
name: null,
|
||||
priority: 0,
|
||||
starts_from: null
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\Discount\Contracts;
|
||||
|
||||
interface CartRule
|
||||
{
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\Discount\Contracts;
|
||||
|
||||
interface CartRuleChannels
|
||||
{ }
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\Discount\Contracts;
|
||||
|
||||
interface CartRuleCustomerGroups
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\Discount\Contracts;
|
||||
|
||||
interface CatalogRuleProducts
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\Discount\Contracts;
|
||||
|
||||
interface CatalogRuleProductsPrice
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -17,6 +17,7 @@ class CreateCatalogRulesTable extends Migration
|
|||
Schema::dropIfExists('discount_channels');
|
||||
Schema::dropIfExists('discount_rules');
|
||||
Schema::dropIfExists('discounts');
|
||||
Schema::dropIfExists('products_grid');
|
||||
|
||||
Schema::create('catalog_rules', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use Illuminate\Support\Facades\Schema;
|
|||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class RemoveCostColumnFromDatagrid extends Migration
|
||||
class CreateCartRuleTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
|
|
@ -13,8 +13,9 @@ class RemoveCostColumnFromDatagrid extends Migration
|
|||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('products_grid', function (Blueprint $table) {
|
||||
$table->dropColumn('cost');
|
||||
Schema::create('cart_rules', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -25,8 +26,6 @@ class RemoveCostColumnFromDatagrid extends Migration
|
|||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('products_grid', function (Blueprint $table) {
|
||||
$table->string('cost')->nullable();
|
||||
});
|
||||
Schema::dropIfExists('cart_rule');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateCartRuleChannelsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('cart_rule_channels', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('cart_rule_channels');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateCartRuleCustomerGroupsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('cart_rule_customer_groups', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('cart_rule_id')->unsigned();
|
||||
$table->foreign('cart_rule_id')->references('id')->on('cart_rules');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('cart_rule_customer_groups');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateCartRuleProductsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('catalog_rule_products', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('cart_rule_id')->unsigned();
|
||||
$table->foreign('cart_rule_id')->references('id')->on('cart_rules');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('cart_rule_products');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateCartRuleProductsPriceTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('catalog_rule_products_price', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('cart_rule_product_id')->unsigned();
|
||||
$table->foreign('cart_rule_product_id')->references('id')->on('cart_rules');
|
||||
$table->decimal('price', 12, 4);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('cart_rule_products_price');
|
||||
}
|
||||
}
|
||||
|
|
@ -10,6 +10,7 @@ use Webkul\Attribute\Repositories\AttributeRepository as Attribute;
|
|||
use Webkul\Attribute\Repositories\AttributeFamilyRepository as AttributeFamily;
|
||||
use Webkul\Category\Repositories\CategoryRepository as Category;
|
||||
use Webkul\Product\Repositories\ProductFlatRepository as Product;
|
||||
use Webkul\Discount\Repositories\CartRuleRepository as CartRule;
|
||||
|
||||
/**
|
||||
* Cart Rule controller
|
||||
|
|
@ -19,28 +20,90 @@ use Webkul\Product\Repositories\ProductFlatRepository as Product;
|
|||
*/
|
||||
class CartRuleController extends Controller
|
||||
{
|
||||
/**
|
||||
* Initialize _config, a default request parameter with route
|
||||
*/
|
||||
protected $_config;
|
||||
|
||||
/**
|
||||
* Attribute $attribute
|
||||
*/
|
||||
protected $attribute;
|
||||
|
||||
/**
|
||||
* AttributeFamily $attributeFamily
|
||||
*/
|
||||
protected $attributeFamily;
|
||||
|
||||
/**
|
||||
* Category $category
|
||||
*/
|
||||
protected $category;
|
||||
|
||||
/**
|
||||
* Product $product
|
||||
*/
|
||||
protected $product;
|
||||
|
||||
public function __construct(Attribute $attribute, AttributeFamily $attributeFamily, Category $category, Product $product)
|
||||
/**
|
||||
* Property for Cart rule application
|
||||
*/
|
||||
protected $appliedConfig;
|
||||
|
||||
/**
|
||||
* To hold the Cart repository instance
|
||||
*/
|
||||
protected $CartRule;
|
||||
|
||||
public function __construct(Attribute $attribute, AttributeFamily $attributeFamily, Category $category, Product $product, CartRule $CartRule)
|
||||
{
|
||||
$this->_config = request('_config');
|
||||
|
||||
$this->attribute = $attribute;
|
||||
|
||||
$this->attributeFamily = $attributeFamily;
|
||||
|
||||
$this->category = $category;
|
||||
|
||||
$this->product = $product;
|
||||
|
||||
$this->CartRule = $CartRule;
|
||||
|
||||
$this->appliedConfig = [
|
||||
0 => trans('admin::app.promotion.Cart.apply-percent'),
|
||||
1 => trans('admin::app.promotion.Cart.apply-fixed'),
|
||||
2 => trans('admin::app.promotion.Cart.adjust-to-percent'),
|
||||
3 => trans('admin::app.promotion.Cart.adjust-to-value')
|
||||
];
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
return view($this->_config['view'])->with('criteria', [$this->attribute->getNameAndId(), $this->category->getNameAndId()]);
|
||||
return view($this->_config['view']);
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
return view($this->_config['view']);
|
||||
return view($this->_config['view'])->with('criteria', [$this->attribute->getNameAndId(), $this->category->getNameAndId()]);
|
||||
}
|
||||
|
||||
public function store()
|
||||
{
|
||||
$this->validate(request(), [
|
||||
'name' => 'required|string',
|
||||
'description' => 'string',
|
||||
'customer_groups' => 'required|array',
|
||||
'channels' => 'required|array',
|
||||
'starts_from' => 'required|date_format:Y-m-d H:i:s',
|
||||
'ends_till' => 'required|date_format:Y-m-d H:i:s',
|
||||
'apply' => 'numeric|min:1|max:4'
|
||||
]);
|
||||
|
||||
$CartRule = $this->CartRule->create(request()->all());
|
||||
}
|
||||
|
||||
public function fetchAttribute()
|
||||
{
|
||||
return request()->all();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\Discount\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Webkul\Discount\Contracts\CartRule as CartRuleContract;
|
||||
|
||||
class CartRule extends Model implements CartRuleContract
|
||||
{
|
||||
protected $table = 'cart_rules';
|
||||
|
||||
protected $guarded = ['created_at', 'updated_at'];
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\Discount\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Webkul\Discount\Contracts\CartRuleChannels as CartRuleChannelsContract;
|
||||
|
||||
class CartRuleChannels extends Model implements CartRuleChannelsContract
|
||||
{
|
||||
protected $table = 'cart_rule_channels';
|
||||
|
||||
protected $guarded = ['created_at', 'updated_at'];
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\Discount\Models;
|
||||
|
||||
use Konekt\Concord\Proxies\ModelProxy;
|
||||
|
||||
class CartRuleChannelsProxy extends ModelProxy
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\Discount\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Webkul\Discount\Contracts\CartRuleCustomerGroups as CartRuleCustomerGroupContract;
|
||||
|
||||
class CartRuleCustomerGroups extends Model implements CartRuleCustomerGroupContract
|
||||
{
|
||||
protected $table = 'cart_rule_customer_groups';
|
||||
|
||||
protected $guarded = ['created_at', 'updated_at'];
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\Discount\Models;
|
||||
|
||||
use Konekt\Concord\Proxies\ModelProxy;
|
||||
|
||||
class CartRuleCustomerGroupsProxy extends ModelProxy
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\Discount\Models;
|
||||
|
||||
use Konekt\Concord\Proxies\ModelProxy;
|
||||
|
||||
class CartRuleProxy extends ModelProxy
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\Discount\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Webkul\Discount\Contracts\CatalogRuleProducts as CatalogRuleProductsContract;
|
||||
|
||||
class CatalogRuleProducts extends Model implements CatalogRuleProductsContract
|
||||
{
|
||||
protected $table = 'cart_rules_products';
|
||||
|
||||
protected $guarded = ['created_at', 'updated_at'];
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\Discount\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Webkul\Discount\Contracts\CatalogRuleProductsPrice as CatalogRuleProductsPriceContract;
|
||||
|
||||
class CatalogRuleProductsPrice extends Model implements CatalogRuleProductsPriceContract
|
||||
{
|
||||
protected $table = 'cart_rules_products_price';
|
||||
|
||||
protected $guarded = ['created_at', 'updated_at'];
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\Discount\Models;
|
||||
|
||||
use Konekt\Concord\Proxies\ModelProxy;
|
||||
|
||||
class CatalogRuleProductsProxy extends ModelProxy
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\Discount\Models;
|
||||
|
||||
use Konekt\Concord\Proxies\ModelProxy;
|
||||
|
||||
class CatalogRuleProductsPriceProxy extends ModelProxy
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\Discount\Providers;
|
||||
|
||||
use Konekt\Concord\BaseModuleServiceProvider;
|
||||
|
||||
class ModuleServiceProvider extends BaseModuleServiceProvider
|
||||
{
|
||||
protected $models = [
|
||||
\Webkul\Discount\Models\CatalogRule::class,
|
||||
\Webkul\Discount\Models\CatalogRuleChannels::class,
|
||||
\Webkul\Discount\Models\CatalogRuleCustomerGroups::class,
|
||||
\Webkul\Discount\Models\CatalogRuleProducts::class,\Webkul\Discount\Models\CatalogRuleProductsPrice::class,
|
||||
\Webkul\Discount\Models\CartRule::class,
|
||||
\Webkul\Discount\Models\CartRuleChannels::class,
|
||||
\Webkul\Discount\Models\CartRuleCustomerGroups::class,
|
||||
];
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\Discount\Repositories;
|
||||
|
||||
use Webkul\Core\Eloquent\Repository;
|
||||
|
||||
/**
|
||||
* Cart Rule Reposotory
|
||||
*
|
||||
* @author Prashant Singh <prashant.singh852@webkul.com>
|
||||
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
|
||||
*/
|
||||
class CartRuleRepository extends Repository
|
||||
{
|
||||
/**
|
||||
* Specify Model class name
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
function model()
|
||||
{
|
||||
return 'Webkul\Discount\Contracts\CartRule';
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\Product\Contracts;
|
||||
|
||||
interface ProductGrid
|
||||
{
|
||||
}
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateProductsGrid extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('products_grid', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('product_id')->unsigned();
|
||||
$table->foreign('product_id')->references('id')->on('products')->onDelete('cascade');
|
||||
$table->string('attribute_family_name')->nullable();
|
||||
$table->string('sku')->nullable();
|
||||
$table->string('type')->nullable();
|
||||
$table->string('name')->nullable();
|
||||
$table->string('quantity')->default(0);
|
||||
$table->string('cost')->default(0);
|
||||
$table->string('price')->nullable();
|
||||
$table->string('status')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('products_grid');
|
||||
}
|
||||
}
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\Product\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Webkul\Product\Models\Product;
|
||||
use Webkul\Product\Contracts\ProductGrid as ProductGridContract;
|
||||
|
||||
class ProductGrid extends Model implements ProductGridContract
|
||||
{
|
||||
protected $table = 'products_grid';
|
||||
|
||||
protected $fillable = ['product_id', 'sku', 'type', 'attribute_family_name', 'name', 'quantity', 'cost', 'price', 'status'];
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
public function product() {
|
||||
return $this->belongsTo(ProductProxy::modelClass(), 'product_id');
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\Product\Models;
|
||||
|
||||
use Konekt\Concord\Proxies\ModelProxy;
|
||||
|
||||
class ProductGridProxy extends ModelProxy
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -10,7 +10,6 @@ class ModuleServiceProvider extends BaseModuleServiceProvider
|
|||
\Webkul\Product\Models\Product::class,
|
||||
\Webkul\Product\Models\ProductAttributeValue::class,
|
||||
\Webkul\Product\Models\ProductFlat::class,
|
||||
\Webkul\Product\Models\ProductGrid::class,
|
||||
\Webkul\Product\Models\ProductImage::class,
|
||||
\Webkul\Product\Models\ProductInventory::class,
|
||||
\Webkul\Product\Models\ProductOrderedInventory::class,
|
||||
|
|
|
|||
Loading…
Reference in New Issue