Taxes, long intended routes, ACL now prevents login if user already logged in.

This commit is contained in:
prashant-webkul 2018-08-31 11:33:11 +05:30
parent 371012a6be
commit df199f0728
63 changed files with 1638 additions and 182 deletions

View File

@ -71,21 +71,21 @@ class ChannelDataGrid
[
'name' => 'id',
'alias' => 'channel_id',
'alias' => 'channelID',
'type' => 'number',
'label' => 'Channel ID',
'sortable' => true,
],
[
'name' => 'code',
'alias' => 'channel_code',
'alias' => 'channelCode',
'type' => 'string',
'label' => 'Channel Code',
'sortable' => true,
],
[
'name' => 'name',
'alias' => 'channel_name',
'alias' => 'channelName',
'type' => 'string',
'label' => 'Channel Name',
'sortable' => true,
@ -98,7 +98,7 @@ class ChannelDataGrid
'filterable' => [
[
'column' => 'id',
'alias' => 'channelId',
'alias' => 'channelID',
'type' => 'number',
'label' => 'Channel ID',
],

View File

@ -42,7 +42,7 @@ class InventorySourcesDataGrid
'actions' => [
[
'type' => 'Edit',
'route' => route('admin.datagrid.delete'),
'route' => route('admin.datagrid.edit'),
'confirm_text' => 'Do you really edit this record?',
'icon' => 'icon pencil-lg-icon',
], [
@ -110,7 +110,7 @@ class InventorySourcesDataGrid
'filterable' => [
[
'column' => 'id',
'alias' => 'inventoryId',
'alias' => 'inventoryID',
'type' => 'number',
'label' => 'ID',
],

View File

@ -6,7 +6,6 @@ use Illuminate\View\View;
use Webkul\Ui\DataGrid\Facades\ProductGrid;
use Webkul\Channel\Repositories\ChannelRepository;
use Webkul\Product\Repositories\ProductRepository;
/**
* Product DataGrid
*
@ -24,7 +23,6 @@ class ProductDataGrid
public function createProductDataGrid()
{
return ProductGrid::make([
'name' => 'Products',
'table' => 'products as prods',
@ -68,6 +66,7 @@ class ProductDataGrid
'primaryKey' => 'prods.attribute_family_id',
'condition' => '=',
'secondaryKey' => 'attfam.id',
'withAttributes' => false
],
//for getting the attribute values.
@ -77,16 +76,17 @@ class ProductDataGrid
'primaryKey' => 'prods.id',
'condition' => '=',
'secondaryKey' => 'pav.product_id',
'withAttributes' => true
'withAttributes' => true //use this boolean to select records as columns
],
//for getting the inventory quantity of a product
// for getting the inventory quantity of a product
[
'join' => 'leftjoin',
'table' => 'product_inventories as pi',
'primaryKey' => 'prods.id',
'condition' => '=',
'secondaryKey' => 'pi.product_id',
'withAttributes' => false
],
],
@ -123,14 +123,14 @@ class ProductDataGrid
'label' => 'Product Quatity',
'sortable' => false,
],
// [
// 'name' => 'pav.attribute_id',
// 'alias' => 'AttributeID',
// 'type' => 'string',
// 'label' => 'Attribute ID',
// 'sortable' => false,
[
'name' => 'pav.attribute_id',
'alias' => 'AttributeID',
'type' => 'string',
'label' => 'Attribute ID',
'sortable' => false,
// ],
],
],
'filterable' => [

View File

@ -100,24 +100,24 @@ class SliderDataGrid
//don't use aliasing in case of filters
'filterable' => [
// [
// 'column' => 'id',
// 'alias' => 'locale_id',
// 'type' => 'number',
// 'label' => 'ID',
// ],
// [
// 'column' => 'code',
// 'alias' => 'locale_code',
// 'type' => 'string',
// 'label' => 'Code',
// ],
// [
// 'column' => 'name',
// 'alias' => 'locale_name',
// 'type' => 'string',
// 'label' => 'Name',
// ],
[
'column' => 'id',
'alias' => 'locale_id',
'type' => 'number',
'label' => 'ID',
],
[
'column' => 'code',
'alias' => 'locale_code',
'type' => 'string',
'label' => 'Code',
],
[
'column' => 'name',
'alias' => 'locale_name',
'type' => 'string',
'label' => 'Name',
],
],
//don't use aliasing in case of searchables

View File

@ -0,0 +1,160 @@
<?php
namespace Webkul\Admin\DataGrids;
use Illuminate\View\View;
use Webkul\Ui\DataGrid\Facades\DataGrid;
/**
* Tax Rules DataGrid
*
* @author Prashant Singh <prashant.singh852@webkul.com> @prashant-webkul
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/
class TaxRuleDataGrid
{
/**
* The Tax Rule Data
* Grid implementation.
*
* @var TaxRuleDataGrid
*/
public function createTaxRuleDataGrid()
{
return DataGrid::make([
'name' => 'Tax Rule',
'table' => 'tax_rules as tr',
'select' => 'tr.id',
'perpage' => 10,
'aliased' => true, //use this with false as default and true in case of joins
'massoperations' =>[
[
'route' => route('admin.datagrid.delete'),
'method' => 'DELETE',
'label' => 'Delete',
'type' => 'button',
],
[
'route' => route('admin.datagrid.index'),
'method' => 'POST',
'label' => 'View Grid',
'type' => 'select',
'options' =>[
1 => 'Edit',
2 => 'Set',
3 => 'Change Status'
]
],
],
'actions' => [
[
'type' => 'Edit',
'route' => route('admin.datagrid.delete'),
'confirm_text' => 'Do you really wanis?',
'icon' => 'icon pencil-lg-icon',
],
[
'type' => 'Delete',
'route' => route('admin.datagrid.delete'),
'confirm_text' => 'Do you really want to do this?',
'icon' => 'icon trash-icon',
],
],
'join' => [
// [
// 'join' => 'leftjoin',
// 'table' => 'roles as r',
// 'primaryKey' => 'u.role_id',
// 'condition' => '=',
// 'secondaryKey' => 'r.id',
// ]
],
//use aliasing on secodary columns if join is performed
'columns' => [
[
'name' => 'tr.id',
'alias' => 'ID',
'type' => 'number',
'label' => 'ID',
'sortable' => true,
],
[
'name' => 'tr.name',
'alias' => 'Name',
'type' => 'string',
'label' => 'Name',
'sortable' => true,
// 'wrapper' => function ($value, $object) {
// return '<a class="color-red">' . $object->Name . '</a>';
// },
],
[
'name' => 'tr.code',
'alias' => 'code',
'type' => 'string',
'label' => 'Code',
'sortable' => true,
],
],
//don't use aliasing in case of filters
'filterable' => [
[
'column' => 'tr.name',
'alias' => 'Name',
'type' => 'number',
'label' => 'Name'
],
[
'column' => 'tr.id',
'alias' => 'ID',
'type' => 'number',
'label' => 'ID'
],
[
'column' => 'tr.code',
'alias' => 'code',
'type' => 'string',
'label' => 'Code'
]
],
//don't use aliasing in case of searchables
'searchable' => [
[
'column' => 'tr.code',
'type' => 'string',
'label' => 'Code'
],
[
'column' => 'tr.name',
'type' => 'string',
'label' => 'Name'
]
],
'operators' => [
'eq' => "=",
'lt' => "<",
'gt' => ">",
'lte' => "<=",
'gte' => ">=",
'neqs' => "<>",
'neqn' => "!=",
'like' => "like",
'nlike' => "not like",
],
// 'css' => []
]);
}
public function render() {
return $this->createTaxRuleDataGrid()->render();
}
}

View File

@ -25,6 +25,7 @@ class UserDataGrid
{
return DataGrid::make([
'name' => 'Admins',
'table' => 'admins as u',
'select' => 'u.id',
@ -38,23 +39,23 @@ class UserDataGrid
'label' => 'Delete',
'type' => 'button',
],
// [
// 'route' => route('admin.datagrid.index'),
// 'method' => 'POST',
// 'label' => 'View Grid',
// 'type' => 'select',
// 'options' =>[
// 1 => 'Edit',
// 2 => 'Set',
// 3 => 'Change Status'
// ]
// ],
[
'route' => route('admin.datagrid.index'),
'method' => 'POST',
'label' => 'View Grid',
'type' => 'select',
'options' =>[
1 => 'Edit',
2 => 'Set',
3 => 'Change Status'
]
],
],
'actions' => [
[
'type' => 'Edit',
'route' => route('admin.datagrid.delete'),
'confirm_text' => 'Do you really want to do this?',
'confirm_text' => 'Do you really wanis?',
'icon' => 'icon pencil-lg-icon',
],
[
@ -83,8 +84,8 @@ class UserDataGrid
'label' => 'Admin ID',
'sortable' => true,
'wrapper' => function ($value, $object) {
return '<a class="color-red">' . $object->ID . '</a>';
},
return '<a class="color-red">' . $object->ID . '</a>';
},
],
[
'name' => 'u.name',
@ -93,8 +94,8 @@ class UserDataGrid
'label' => 'Name',
'sortable' => true,
'wrapper' => function ($value, $object) {
return '<a class="color-red">' . $object->Name . '</a>';
},
return '<a class="color-red">' . $object->Name . '</a>';
},
],
[
'name' => 'u.email',
@ -117,27 +118,6 @@ class UserDataGrid
'label' => 'Role ID',
'sortable' => true,
],
// [
// 'name' => 'a.first_name',
// 'type' => 'string',
// 'label' => 'Admin Name',
// 'sortable' => true,
// 'filterable' => true,
// // will create on run time query
// // 'filter' => [
// // 'function' => 'where', // orwhere
// // 'condition' => ['name', '=', 'Admin'] // multiarray
// // ],
// 'attributes' => [
// 'class' => 'class-a class-b',
// 'data-attr' => 'whatever you want',
// 'onclick' => "window.alert('alert from datagrid column')"
// ],
// 'wrapper' => function ($value, $object) {
// return '<a href="'.$value.'">' . $object->first_name . '</a>';
// },
// ],
],
//don't use aliasing in case of filters
'filterable' => [

View File

@ -24,6 +24,8 @@ class DashboardController extends Controller
public function __construct()
{
$this->_config = request('_config');
$this->middleware('admin');
}
public function index()
{

View File

@ -15,6 +15,7 @@ use Webkul\Ui\DataGrid\Facades\DataGrid;
*/
class DataGridController extends Controller
{
/**
* Display a listing of the resource.
*

View File

@ -9,7 +9,7 @@ Route::group(['middleware' => ['web']], function () {
Route::post('/login', 'Webkul\User\Http\Controllers\SessionController@store')->defaults('_config', [
'redirect' => 'admin.dashboard.index'
])->name('admin.forget-password.store');
])->name('admin.session.store');
// Forget Password Routes
@ -140,6 +140,8 @@ Route::group(['middleware' => ['web']], function () {
Route::any('datagrid/massaction/delete', 'Webkul\Admin\Http\Controllers\DataGridController@massDelete')->name('admin.datagrid.delete');
Route::any('datagrid/massaction/edit','Webkul\Admin\Http\Controllers\DataGridController@massUpdate')->name('admin.datagrid.edit');
// User Routes
Route::get('/users', 'Webkul\User\Http\Controllers\UserController@index')->defaults('_config', [
'view' => 'admin::users.users.index'
@ -313,6 +315,51 @@ Route::group(['middleware' => ['web']], function () {
Route::post('/slider/create','Webkul\Shop\Http\Controllers\SliderController@store')->defaults('_config',[
'redirect' => 'admin::sliders.index'
])->name('admin.sliders.store');
//tax routes
Route::prefix('tax')->group(function () {
Route::get('tax', 'Webkul\Core\Http\Controllers\TaxController@index')->defaults('_config', [
'view' => 'admin::tax.tax'
])->name('admin.tax.index');
// tax rule
Route::get('taxrule', 'Webkul\Core\Http\Controllers\TaxRuleController@show')->defaults('_config', [
'view' => 'admin::tax.taxrule.taxrule'
])->name('admin.taxrule.show');
Route::post('taxrule', 'Webkul\Core\Http\Controllers\TaxRuleController@create')->defaults('_config', [
'redirect' => 'admin.tax.index'
])->name('admin.taxrule.create');
Route::get('/taxrule/edit/{id}', 'Webkul\Core\Http\Controllers\TaxRuleController@create')->defaults('_config', [
'redirect' => 'admin.tax.index'
])->name('admin.taxrule.edit');
Route::put('/taxrule/edit/{id}', 'Webkul\Core\Http\Controllers\TaxRuleController@create')->defaults('_config', [
'redirect' => 'admin.tax.index'
])->name('admin.taxrule.update');
//tax rule ends
//tax rate
Route::get('taxrate', 'Webkul\Core\Http\Controllers\TaxRateController@show')->defaults('_config', [
'view' => 'admin::tax.taxrate.taxrate'
])->name('admin.taxrate.show');
Route::post('taxrate', 'Webkul\Core\Http\Controllers\TaxRateController@create')->defaults('_config', [
'redirect' => 'admin.tax.index'
])->name('admin.taxrate.create');
Route::get('taxrate/edit/{id}', 'Webkul\Core\Http\Controllers\TaxRateController@edit')->defaults('_config', [
'view' => 'admin::tax.taxrate.edit.edit'
])->name('admin.taxrate.store');
Route::put('taxrate/update/{id}', 'Webkul\Core\Http\Controllers\TaxRateController@update')->defaults('_config', [
'redirect' => 'admin.tax.index'
])->name('admin.taxrate.update');
});
//tax rate ends
});
});
});

View File

@ -77,6 +77,12 @@ class EventServiceProvider extends ServiceProvider
$menu->add('settings.users.roles', 'Roles', 'admin.roles.index', 2, '');
$menu->add('settings.sliders', 'Create Sliders', 'admin.sliders.index', 8, '');
$menu->add('settings.tax', 'Taxes', 'admin.tax.index', 9, '');
$menu->add('settings.tax.taxrule', 'Add Tax Rules', 'admin.tax.index', 1, '');
$menu->add('settings.tax.taxrate', 'Add Tax Rates', 'admin.taxrate.show', 2, '');
});
}

View File

@ -174,6 +174,38 @@ return [
'meta_keywords' => 'Meta Keywords',
]
],
'configuration' => [
'tax' => [
'title' => 'Taxes',
'add-title' => 'Add Tax Rule'
],
'taxrule' => [
'title' => 'Add Tax Rule',
'create' => 'Create Tax Rule',
'general' => 'Tax Rule',
'name' => 'Name',
'code' => 'Code',
'description' => 'Description',
'select-taxrates' => 'Select Tax Rates'
],
'taxrate' => [
'title' => 'Add Tax Rate',
'general' => 'Tax Rate',
'identifier' => 'Identifier',
'is_zip' => 'Enable Zip Range',
'zip_from' => 'Zip From',
'zip_to' => 'Zip To',
'state' => 'State',
'country' => 'Country',
'tax_rate' => 'Rate',
'edit' => [
'title' => 'Edit Tax Rate',
'edit-button-title' => 'Edit Rate'
]
],
],
'settings' => [
'locales' => [
'title' => 'Locales',

View File

@ -0,0 +1,22 @@
@extends('admin::layouts.content')
@section('content')
<div class="content">
<div class="page-header">
<div class="page-title">
<h1>{{ __('admin::app.configuration.tax.title') }}</h1>
</div>
<div class="page-action">
<a href="{{ route('admin.taxrule.show') }}" class="btn btn-lg btn-primary">
{{ __('admin::app.configuration.tax.add-title') }}
</a>
</div>
</div>
<div class="page-content">
<h2>Tax Rules DataGrid Will be here.</h2>
<span>Render the tax rules datagrid here.</span>
</div>
</div>
@stop

View File

@ -0,0 +1,93 @@
@extends('admin::layouts.content')
@section('page_title')
{{ __('admin::app.configuration.taxrate.title') }}
@stop
@section('content')
<div class="content">
<form method="POST" action="{{ route('admin.taxrate.update', $data['id']) }}" @submit.prevent="onSubmit">
<div class="page-header">
<div class="page-title">
<h1>{{ __('admin::app.configuration.taxrate.edit.title') }}</h1>
</div>
<div class="page-action">
<button type="submit" class="btn btn-lg btn-primary">
{{ __('admin::app.configuration.taxrate.edit.edit-button-title') }}
</button>
</div>
</div>
<div class="page-content">
<div class="form-container">
@method('PUT')
@csrf()
<accordian :title="'{{ __('admin::app.configuration.taxrate.general') }}'" :active="true">
<div slot="body">
<div class="control-group" :class="[errors.has('identifier') ? 'has-error' : '']">
<label for="identifier" class="required">{{ __('admin::app.configuration.taxrate.identifier') }}</label>
<input v-validate="'required'" class="control" id="identifier" name="identifier" value="{{ $data['identifier'] }}"/>
<span class="control-error" v-if="errors.has('identifier')">@{{ errors.first('identifier') }}</span>
</div>
<div class="control-group">
<span class="checkbox">
<input type="checkbox" id="is_zip" name="is_zip">
<label class="checkbox-view" for="is_zip"></label>
Enable Zip Range
</span>
</div>
<div class="control-group" :class="[errors.has('zip_from') ? 'has-error' : '']">
<label for="zip_from" class="required">{{ __('admin::app.configuration.taxrate.zip_from') }}</label>
<input v-validate="'numeric'" class="control" id="zip_from" name="zip_from" value="{{ $data['zip_from'] }}" />
<span class="control-error" v-if="errors.has('zip_from')">@{{ errors.first('zip_from') }}</span>
</div>
<div class="control-group" :class="[errors.has('zip_to') ? 'has-error' : '']">
<label for="zip_to" class="required">{{ __('admin::app.configuration.taxrate.zip_to') }}</label>
<input v-validate="'numeric'" class="control" id="zip_to" name="zip_to" value="{{ $data['zip_to'] }}" />
<span class="control-error" v-if="errors.has('zip_to')">@{{ errors.first('zip_to') }}</span>
</div>
<div class="control-group" :class="[errors.has('state') ? 'has-error' : '']">
<label for="state" class="required">{{ __('admin::app.configuration.taxrate.state') }}</label>
<input v-validate="'required'" class="control" id="state" name="state" value="{{ $data['state'] }}" />
<span class="control-error" v-if="errors.has('state')">@{{ errors.first('state') }}</span>
</div>
<div class="control-group" :class="[errors.has('country') ? 'has-error' : '']">
<label for="country" class="required">{{ __('admin::app.configuration.taxrate.country') }}</label>
<input v-validate="'required'" class="control" id="country" name="country" value="{{ $data['country'] }}" />
<span class="control-error" v-if="errors.has('country')">@{{ errors.first('country') }}</span>
</div>
<div class="control-group" :class="[errors.has('tax_rate') ? 'has-error' : '']">
<label for="tax_rate" class="required">{{ __('admin::app.configuration.taxrate.tax_rate') }}</label>
<input v-validate="'required'" class="control" id="tax_rate" name="tax_rate" value="{{ $data['tax_rate'] }}" />
<span class="control-error" v-if="errors.has('tax_rate')">@{{ errors.first('tax_rate') }}</span>
</div>
</div>
</accordian>
</div>
</div>
</form>
</div>
@stop

View File

@ -0,0 +1,93 @@
@extends('admin::layouts.content')
@section('page_title')
{{ __('admin::app.configuration.taxrate.title') }}
@stop
@section('content')
<div class="content">
<form method="POST" action="{{ route('admin.taxrate.create') }}" @submit.prevent="onSubmit">
<div class="page-header">
<div class="page-title">
<h1>{{ __('admin::app.configuration.taxrate.title') }}</h1>
</div>
<div class="page-action">
<button type="submit" class="btn btn-lg btn-primary">
{{ __('admin::app.configuration.taxrule.create') }}
</button>
</div>
</div>
<div class="page-content">
<div class="form-container">
@csrf()
<accordian :title="'{{ __('admin::app.configuration.taxrate.general') }}'" :active="true">
<div slot="body">
<div class="control-group" :class="[errors.has('identifier') ? 'has-error' : '']">
<label for="identifier" class="required">{{ __('admin::app.configuration.taxrate.identifier') }}</label>
<input v-validate="'required'" class="control" id="identifier" name="identifier" value="{{ old('identifier') }}"/>
<span class="control-error" v-if="errors.has('identifier')">@{{ errors.first('identifier') }}</span>
</div>
<div class="control-group">
<span class="checkbox">
<input type="checkbox" id="is_zip" name="is_zip">
<label class="checkbox-view" for="is_zip"></label>
Enable Zip Range
</span>
</div>
<div class="control-group" :class="[errors.has('zip_from') ? 'has-error' : '']">
<label for="zip_from" class="required">{{ __('admin::app.configuration.taxrate.zip_from') }}</label>
<input v-validate="'numeric'" class="control" id="zip_from" name="zip_from" value="{{ old('zip_from') }}"/>
<span class="control-error" v-if="errors.has('zip_from')">@{{ errors.first('zip_from') }}</span>
</div>
<div class="control-group" :class="[errors.has('zip_to') ? 'has-error' : '']">
<label for="zip_to" class="required">{{ __('admin::app.configuration.taxrate.zip_to') }}</label>
<input v-validate="'numeric'" class="control" id="zip_to" name="zip_to" value="{{ old('zip_to') }}"/>
<span class="control-error" v-if="errors.has('zip_to')">@{{ errors.first('zip_to') }}</span>
</div>
<div class="control-group" :class="[errors.has('state') ? 'has-error' : '']">
<label for="state" class="required">{{ __('admin::app.configuration.taxrate.state') }}</label>
<input v-validate="'required'" class="control" id="state" name="state" value="{{ old('state') }}"/>
<span class="control-error" v-if="errors.has('state')">@{{ errors.first('state') }}</span>
</div>
<div class="control-group" :class="[errors.has('country') ? 'has-error' : '']">
<label for="country" class="required">{{ __('admin::app.configuration.taxrate.country') }}</label>
<input v-validate="'required'" class="control" id="country" name="country" value="{{ old('country') }}"/>
<span class="control-error" v-if="errors.has('country')">@{{ errors.first('country') }}</span>
</div>
<div class="control-group" :class="[errors.has('tax_rate') ? 'has-error' : '']">
<label for="tax_rate" class="required">{{ __('admin::app.configuration.taxrate.tax_rate') }}</label>
<input v-validate="'required'" class="control" id="tax_rate" name="tax_rate" value="{{ old('tax_rate') }}"/>
<span class="control-error" v-if="errors.has('tax_rate')">@{{ errors.first('tax_rate') }}</span>
</div>
</div>
</accordian>
</div>
</div>
</form>
</div>
@stop

View File

@ -0,0 +1,93 @@
@extends('admin::layouts.content')
@section('page_title')
{{ __('admin::app.configuration.taxrate.title') }}
@stop
@section('content')
<div class="content">
<form method="POST" action="{{ route('admin.taxrate.update', $data['id']) }}" @submit.prevent="onSubmit">
<div class="page-header">
<div class="page-title">
<h1>{{ __('admin::app.configuration.taxrate.edit.title') }}</h1>
</div>
<div class="page-action">
<button type="submit" class="btn btn-lg btn-primary">
{{ __('admin::app.configuration.taxrate.edit.edit-button-title') }}
</button>
</div>
</div>
<div class="page-content">
<div class="form-container">
@method('PUT')
@csrf()
<accordian :title="'{{ __('admin::app.configuration.taxrate.general') }}'" :active="true">
<div slot="body">
<div class="control-group" :class="[errors.has('identifier') ? 'has-error' : '']">
<label for="identifier" class="required">{{ __('admin::app.configuration.taxrate.identifier') }}</label>
<input v-validate="'required'" class="control" id="identifier" name="identifier" value="{{ $data['identifier'] }}"/>
<span class="control-error" v-if="errors.has('identifier')">@{{ errors.first('identifier') }}</span>
</div>
<div class="control-group">
<span class="checkbox">
<input type="checkbox" id="is_zip" name="is_zip">
<label class="checkbox-view" for="is_zip"></label>
Enable Zip Range
</span>
</div>
<div class="control-group" :class="[errors.has('zip_from') ? 'has-error' : '']">
<label for="zip_from" class="required">{{ __('admin::app.configuration.taxrate.zip_from') }}</label>
<input v-validate="'numeric'" class="control" id="zip_from" name="zip_from" value="{{ $data['zip_from'] }}" />
<span class="control-error" v-if="errors.has('zip_from')">@{{ errors.first('zip_from') }}</span>
</div>
<div class="control-group" :class="[errors.has('zip_to') ? 'has-error' : '']">
<label for="zip_to" class="required">{{ __('admin::app.configuration.taxrate.zip_to') }}</label>
<input v-validate="'numeric'" class="control" id="zip_to" name="zip_to" value="{{ $data['zip_to'] }}" />
<span class="control-error" v-if="errors.has('zip_to')">@{{ errors.first('zip_to') }}</span>
</div>
<div class="control-group" :class="[errors.has('state') ? 'has-error' : '']">
<label for="state" class="required">{{ __('admin::app.configuration.taxrate.state') }}</label>
<input v-validate="'required'" class="control" id="state" name="state" value="{{ $data['state'] }}" />
<span class="control-error" v-if="errors.has('state')">@{{ errors.first('state') }}</span>
</div>
<div class="control-group" :class="[errors.has('country') ? 'has-error' : '']">
<label for="country" class="required">{{ __('admin::app.configuration.taxrate.country') }}</label>
<input v-validate="'required'" class="control" id="country" name="country" value="{{ $data['country'] }}" />
<span class="control-error" v-if="errors.has('country')">@{{ errors.first('country') }}</span>
</div>
<div class="control-group" :class="[errors.has('tax_rate') ? 'has-error' : '']">
<label for="tax_rate" class="required">{{ __('admin::app.configuration.taxrate.tax_rate') }}</label>
<input v-validate="'required'" class="control" id="tax_rate" name="tax_rate" value="{{ $data['tax_rate'] }}" />
<span class="control-error" v-if="errors.has('tax_rate')">@{{ errors.first('tax_rate') }}</span>
</div>
</div>
</accordian>
</div>
</div>
</form>
</div>
@stop

View File

@ -0,0 +1,76 @@
@extends('admin::layouts.content')
@section('page_title')
{{ __('admin::app.configuration.taxrule.title') }}
@stop
@section('content')
<div class="content">
<form method="POST" action="{{ route('admin.taxrule.create') }}" @submit.prevent="onSubmit">
<div class="page-header">
<div class="page-title">
<h1>{{ __('admin::app.configuration.taxrule.title') }}</h1>
</div>
<div class="page-action">
<button type="submit" class="btn btn-lg btn-primary">
{{ __('admin::app.configuration.taxrule.create') }}
</button>
</div>
</div>
<div class="page-content">
<div class="form-container">
@csrf()
<accordian :title="'{{ __('admin::app.configuration.taxrule.general') }}'" :active="true">
<div slot="body">
<div class="control-group" :class="[errors.has('code') ? 'has-error' : '']">
<label for="code" class="required">{{ __('admin::app.configuration.taxrule.code') }}</label>
<input v-validate="'required'" class="control" id="code" name="code" value="{{ old('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.configuration.taxrule.name') }}</label>
<input v-validate="'required'" class="control" id="name" name="name" value="{{ old('name') }}"/>
<span class="control-error" v-if="errors.has('name')">@{{ errors.first('name') }}</span>
</div>
<div class="control-group" :class="[errors.has('description') ? 'has-error' : '']">
<label for="description" class="required">{{ __('admin::app.configuration.taxrule.description') }}</label>
<textarea v-validate="'required'" class="control" id="description" name="description" value="{{ old('description') }}"></textarea>
<span class="control-error" v-if="errors.has('description')">@{{ errors.first('description') }}</span>
</div>
<div class="control-group" :class="[errors.has('taxrates') ? 'has-error' : '']">
<label for="taxrates" class="required">{{ __('admin::app.configuration.taxrule.select-taxrates') }}</label>
<select multiple="multiple" v-validate="'required'" class="control" id="taxrates" name="taxrates[]" value="{{ old('taxrates') }}">
@foreach($taxRates as $taxRate)
<option value="{{$taxRate['id']}}">{{$taxRate['identifier']}}</option>
@endforeach
</select>
<span class="control-error" v-if="errors.has('taxrates')">@{{ errors.first('taxrates') }}</span>
</div>
</div>
</accordian>
</div>
</div>
</form>
</div>
@stop

View File

@ -14,7 +14,7 @@
<h1>{{ __('admin::app.users.sessions.title') }}</h1>
<form method="POST" action="login" @submit.prevent="onSubmit">
<form method="POST" action="{{ route('admin.session.store') }}" @submit.prevent="onSubmit">
@csrf
<div class="control-group" :class="[errors.has('email') ? 'has-error' : '']">
@ -40,14 +40,14 @@
{{ __('admin::app.users.sessions.remember-me') }}
</span>
</div>
<div class="button-group">
<button class="btn btn-xl btn-primary">{{ __('admin::app.users.sessions.submit-btn-title') }}</button>
</div>
</form>
</div>
</div>
</div>

View File

@ -6,8 +6,6 @@
@section('content')
@inject ('datagrid', 'Webkul\Admin\Datagrids\User')
<div class="content">
<div class="page-header">
<div class="page-title">

View File

@ -21,7 +21,7 @@ class AttributeController extends Controller
* @var array
*/
protected $_config;
/**
* AttributeRepository object
*
@ -37,6 +37,8 @@ class AttributeController extends Controller
*/
public function __construct(Attribute $attribute)
{
$this->middleware('admin');
$this->attribute = $attribute;
$this->_config = request('_config');
@ -109,7 +111,7 @@ class AttributeController extends Controller
'admin_name' => 'required',
'type' => 'required'
]);
$this->attribute->update(request()->all(), $id);
session()->flash('success', 'Attribute updated successfully.');

View File

@ -22,7 +22,7 @@ class AttributeFamilyController extends Controller
* @var array
*/
protected $_config;
/**
* AttributeFamilyRepository object
*
@ -38,6 +38,8 @@ class AttributeFamilyController extends Controller
*/
public function __construct(AttributeFamily $attributeFamily)
{
$this->middleware('admin');
$this->attributeFamily = $attributeFamily;
$this->_config = request('_config');
@ -62,7 +64,7 @@ class AttributeFamilyController extends Controller
public function create(Attribute $attribute)
{
$attributeFamily = $this->attributeFamily->with(['attribute_groups.custom_attributes'])->findOneByField('code', 'default');
$custom_attributes = $attribute->all(['id', 'code', 'admin_name', 'type']);
return view($this->_config['view'], compact('custom_attributes', 'attributeFamily'));
@ -116,7 +118,7 @@ class AttributeFamilyController extends Controller
'code' => ['required', 'unique:attribute_families,code,' . $id, new \Webkul\Core\Contracts\Validations\Code],
'name' => 'required'
]);
$this->attributeFamily->update(request()->all(), $id);

View File

@ -4,6 +4,7 @@ namespace Webkul\Attribute\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Routing\Router;
use Webkul\User\Http\Middleware\RedirectIfNotAdmin;
class AttributeServiceProvider extends ServiceProvider
{
@ -14,6 +15,8 @@ class AttributeServiceProvider extends ServiceProvider
*/
public function boot(Router $router)
{
$router->aliasMiddleware('admin', RedirectIfNotAdmin::class);
$this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations');
}
@ -24,6 +27,6 @@ class AttributeServiceProvider extends ServiceProvider
*/
public function register()
{
}
}

View File

@ -20,7 +20,7 @@ class CategoryController extends Controller
* @var array
*/
protected $_config;
/**
* CategoryRepository object
*
@ -36,6 +36,8 @@ class CategoryController extends Controller
*/
public function __construct(Category $category)
{
$this->middleware('admin');
$this->category = $category;
$this->_config = request('_config');

View File

@ -5,6 +5,7 @@ namespace Webkul\Category\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Foundation\AliasLoader;
use Illuminate\Routing\Router;
use Webkul\User\Http\Middleware\RedirectIfNotAdmin;
class CategoryServiceProvider extends ServiceProvider
{
@ -15,6 +16,8 @@ class CategoryServiceProvider extends ServiceProvider
*/
public function boot(Router $router)
{
$router->aliasMiddleware('admin', RedirectIfNotAdmin::class);
$this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations');
}
@ -25,6 +28,6 @@ class CategoryServiceProvider extends ServiceProvider
*/
public function register()
{
}
}

View File

@ -0,0 +1,42 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateTaxRulesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('tax_rules', function (Blueprint $table) {
$table->increments('id');
$table->integer('channel_id')->unsigned();
$table->foreign('channel_id')->references('id')->on('channels')->onDelete('cascade');
$table->string('code')->unique();
$table->string('name')->unique();
$table->longtext('description');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('tax_rules');
}
}

View File

@ -0,0 +1,46 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateTaxRatesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('tax_rates', function (Blueprint $table) {
$table->increments('id');
$table->string('identifier')->unique();
$table->boolean('is_zip_from')->default(0);
$table->integer('zip_from')->unsigned()->nullable();
$table->integer('zip_to')->unsigned()->nullable();
$table->string('state');
$table->string('country');
$table->float('tax_rate', 6, 4);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('tax_rates');
}
}

View File

@ -0,0 +1,42 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateTaxMapTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('tax_map', function (Blueprint $table) {
$table->increments('id');
$table->integer('tax_rule_id')->unsigned();
$table->foreign('tax_rule_id')->references('id')->on('tax_rules')->onDelete('cascade');
$table->integer('tax_rate_id')->unsigned();
$table->foreign('tax_rate_id')->references('id')->on('tax_rates')->onDelete('cascade');
$table->unique(['tax_rule_id', 'tax_rate_id'], 'tax_map_index_unique');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('tax_map');
}
}

View File

@ -21,7 +21,7 @@ class ChannelController extends Controller
* @var array
*/
protected $_config;
/**
* ChannelRepository object
*
@ -37,6 +37,8 @@ class ChannelController extends Controller
*/
public function __construct(Channel $channel)
{
$this->middleware('admin');
$this->channel = $channel;
$this->_config = request('_config');

View File

@ -20,7 +20,7 @@ class CountryController extends Controller
* @var array
*/
protected $_config;
/**
* CountryRepository object
*
@ -36,6 +36,8 @@ class CountryController extends Controller
*/
public function __construct(Country $country)
{
$this->middleware('admin');
$this->country = $country;
$this->_config = request('_config');

View File

@ -20,7 +20,7 @@ class CurrencyController extends Controller
* @var array
*/
protected $_config;
/**
* CurrencyRepository object
*
@ -36,6 +36,8 @@ class CurrencyController extends Controller
*/
public function __construct(Currency $currency)
{
$this->middleware('admin');
$this->currency = $currency;
$this->_config = request('_config');
@ -81,7 +83,7 @@ class CurrencyController extends Controller
return redirect()->route($this->_config['redirect']);
}
/**
* Remove the specified resource from storage.
*

View File

@ -21,14 +21,14 @@ class ExchangeRateController extends Controller
* @var array
*/
protected $_config;
/**
* ExchangeRateRepository object
*
* @var array
*/
protected $exchangeRate;
/**
* CurrencyRepository object
*
@ -45,6 +45,8 @@ class ExchangeRateController extends Controller
*/
public function __construct(ExchangeRate $exchangeRate, Currency $currency)
{
$this->middleware('admin');
$this->exchangeRate = $exchangeRate;
$this->currency = $currency;
@ -129,7 +131,7 @@ class ExchangeRateController extends Controller
'target_currency' => 'required',
'ratio' => 'required|numeric'
]);
$this->exchangeRate->update(request()->all(), $id);
session()->flash('success', 'Exchange rate updated successfully.');

View File

@ -20,7 +20,7 @@ class LocaleController extends Controller
* @var array
*/
protected $_config;
/**
* LocaleRepository object
*
@ -36,6 +36,8 @@ class LocaleController extends Controller
*/
public function __construct(Locale $locale)
{
$this->middleware('admin');
$this->locale = $locale;
$this->_config = request('_config');

View File

@ -0,0 +1,92 @@
<?php
namespace Webkul\Core\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Webkul\Core\Repositories\ChannelRepository as Channel;
use Webkul\Core\Repositories\TaxRuleRepository as TaxRule;
use Webkul\Core\Repositories\TaxRateRepository as TaxRate;
use Webkul\Core\Repositories\TaxMapRepository as TaxMap;
/**
* Tax controller
*
* @author Prashant Singh <prashant.singh852@webkul.com>
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/
class TaxController extends Controller
{
/**
* Contains route related configuration
*
* @var array
*/
protected $_config;
/**
* ChannelRepository object
*
* @var array
*/
protected $channel;
/**
* Tax Rule Repository object
*
* @var array
*/
protected $taxRule;
/**
* Tax Rate Repository object
*
* @var array
*/
protected $taxRate;
/**
* Tax Map Repository object
*
* @var array
*/
protected $taxMap;
/**
* Create a new controller instance.
*
* @param Webkul\Core\Repositories\ChannelRepository $channel
* @param Webkul\Core\Repositories\TaxRuleRepository $taxRule
* @param Webkul\Core\Repositories\TaxRateRepository $taxRate
* @param Webkul\Core\Repositories\TaxMapRepository $taxMap
* @return void
*/
public function __construct(Channel $channel, TaxRule $taxRule, TaxRate $taxRate, TaxMap $taxMap)
{
$this->middleware('admin');
$this->channel = $channel;
$this->taxRule = $taxRule;
$this->taxRate = $taxRate;
$this->taxMap = $taxMap;
$this->_config = request('_config');
}
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
return view($this->_config['view']);
}
}

View File

@ -0,0 +1,133 @@
<?php
namespace Webkul\Core\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Webkul\Core\Repositories\TaxRateRepository as TaxRate;
/**
* Tax controller
*
* @author Prashant Singh <prashant.singh852@webkul.com>
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/
class TaxRateController extends Controller
{
/**
* Contains route related configuration
*
* @var array
*/
protected $_config;
/**
* Tax Rate Repository object
*
* @var array
*/
protected $taxRate;
/**
* Create a new controller instance.
*
* @param Webkul\Core\Repositories\TaxRateRepository $taxRate
* @return void
*/
public function __construct(TaxRate $taxRate)
{
$this->middleware('admin');
$this->taxRate = $taxRate;
$this->_config = request('_config');
}
/**
* Display a listing of the resource.
*
* @return view
*/
public function show()
{
return view($this->_config['view']);
}
/**
* Create the tax rate
*
* @return mixed
*/
public function create() {
$this->validate(request(), [
'identifier' => 'required|string|unique:tax_rates,identifier',
'is_zip' => 'sometimes|confirmed',
'zip_from' => 'nullable|numeric|required_with:is_zip',
'zip_to' => 'nullable|numeric|required_with:is_zip,zip_from',
'state' => 'required|string',
'country' => 'required|string',
'tax_rate' => 'required|numeric'
]);
if($this->taxRate->create(request()->input())) {
session()->flash('success', 'Tax Rate Created Successfully');
return redirect()->route($this->_config['redirect']);
} else {
session()->flash('error', 'Cannot Create Tax Rate');
return redirect()->back();
}
return redirect()->back();
}
/**
* Show the edit form
* for the previously
* created tax rates.
*
* @return mixed
*/
public function edit($id) {
$data = collect($this->taxRate->findOneByField('id', $id));
return view($this->_config['view'])->with('data', $data);
}
/**
* Edit the previous
* tax rate
*
* @return mixed
*/
public function update($id) {
$this->validate(request(), [
'identifier' => 'required|string|unique:tax_rates,identifier,'.$id,
'is_zip' => 'sometimes|confirmed',
'zip_from' => 'nullable|numeric|required_with:is_zip',
'zip_to' => 'nullable|numeric|required_with:is_zip,zip_from',
'state' => 'required|string',
'country' => 'required|string',
'tax_rate' => 'required|numeric'
]);
if($this->taxRate->update(request()->input(), $id)) {
session()->flash('success', 'Tax Rate Updated Successfully');
return redirect()->route($this->_config['redirect']);
} else {
session()->flash('error', 'Cannot Create Tax Rate');
return redirect()->back();
}
return redirect()->back();
}
}

View File

@ -0,0 +1,144 @@
<?php
namespace Webkul\Core\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Webkul\Channel\Channel as Channel;
use Webkul\Core\Repositories\TaxRuleRepository as TaxRule;
use Webkul\Core\Repositories\TaxRateRepository as TaxRate;
use Webkul\Core\Repositories\TaxMapRepository as TaxMap;
/**
* Tax controller
*
* @author Prashant Singh <prashant.singh852@webkul.com>
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/
class TaxRuleController extends Controller
{
/**
* Contains route related configuration
*
* @var array
*/
protected $_config;
/**
* Contains the current
* channel.
*
* @var string
*/
protected $currentChannelId;
/**
* Tax Rule Repository object
*
* @var array
*/
protected $taxRule;
/**
* Tax Map Repository object
*
* @var array
*/
protected $taxMap;
/**
* Create a new controller instance.
*
* @param Webkul\Core\Repositories\TaxRuleRepository $taxRule
* @return void
*/
public function __construct(TaxRule $taxRule, TaxRate $taxRate, TaxMap $taxMap)
{
$this->middleware('admin');
$this->currentChannelId = core()->getCurrentChannel()->id;
$this->taxRule = $taxRule;
$this->taxRate = $taxRate;
$this->taxMap = $taxMap;
$this->_config = request('_config');
}
/**
* Function to show
* the tax rule form
*
* @return view
*/
public function show()
{
return view($this->_config['view'])->with('taxRates', $this->taxRate->all());
}
/**
* Function to create
* the tax rule.
*
* @return view
*/
public function create()
{
$data = request()->input();
$this->validate(request(), [
'code' => 'required|string|unique:tax_rules,id',
'name' => 'required|string|unique:tax_rules,name',
'description' => 'required|string'
]);
$data['channel_id'] = $this->currentChannelId;
unset($data['_token']);
if($currentTaxRule = $this->taxRule->create($data)) {
$allTaxRules = $data['taxrates'];
foreach ($allTaxRules as $index => $taxRuleId) {
$taxMap['tax_rule'] = $currentTaxRule->id;
$taxMap['tax_rate'] = $taxRuleId;
if ($this->taxMap->create($taxMap)) {
continue;
} else {
return redirect()->action('TaxRuleController@performRollback',[
'taxRuleId' => $taxRuleId
]);
}
}
session()->flash('success', 'New Tax Rule Created');
return redirect()->route('admin.tax.index');
} else {
session()->flash('error', 'Cannot create the tax rule');
}
return view($this->_config['view']);
}
/**
* To perform the rollback
* if in anycase the taxMap
* records creates any problem.
*
* @return mixed
*/
public function performRollback($taxRuleId) {
if($this->taxRule->delete($taxRuleId)) {
Session()->flash('error', 'Cannot Create Tax Rule');
return redirect()->route('admin.tax.index');
}
}
}

View File

@ -0,0 +1,20 @@
<?php
namespace Webkul\Core\Models;
use Illuminate\Database\Eloquent\Model;
class TaxMap extends Model
{
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $table = 'tax_map';
protected $fillable = [
'channel_id', 'tax_rule', 'tax_rate'
];
}

View File

@ -0,0 +1,20 @@
<?php
namespace Webkul\Core\Models;
use Illuminate\Database\Eloquent\Model;
class TaxRate extends Model
{
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $table = 'tax_rates';
protected $fillable = [
'identifier', 'is_zip_from', 'zip_from', 'zip_to', 'state', 'country', 'tax_rate'
];
}

View File

@ -0,0 +1,20 @@
<?php
namespace Webkul\Core\Models;
use Illuminate\Database\Eloquent\Model;
class TaxRule extends Model
{
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $table = 'tax_rules';
protected $fillable = [
'code', 'name' ,'description'
];
}

View File

@ -7,6 +7,8 @@ use Illuminate\Support\Facades\Validator;
use Illuminate\Routing\Router;
use Illuminate\Foundation\AliasLoader;
use Webkul\Core\Http\Middleware\Locale;
use Webkul\User\Http\Middleware\RedirectIfNotAdmin;
use Webkul\Customer\Http\Middleware\RedirectIfNotCustomer;
use Webkul\Core\Core;
use Webkul\Core\Facades\CoreFacade;
@ -27,6 +29,10 @@ class CoreServiceProvider extends ServiceProvider
$router->aliasMiddleware('locale', Locale::class);
$router->aliasMiddleware('admin', RedirectIfNotAdmin::class);
$router->aliasMiddleware('customer', RedirectIfNotCustomer::class);
$this->publishes([
__DIR__ . '/../../publishable/lang' => public_path('vendor/webkul/core/lang'),
], 'public');

View File

@ -1,7 +1,7 @@
<?php
<?php
namespace Webkul\Core\Repositories;
use Webkul\Core\Eloquent\Repository;
/**

View File

@ -0,0 +1,50 @@
<?php
namespace Webkul\Core\Repositories;
use Webkul\Core\Eloquent\Repository;
/**
* Tax Map Reposotory
*
* @author Prashant Singh <prashant.singh852@webkul.com>
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/
class TaxMapRepository extends Repository
{
/**
* Specify Model class name
*
* @return mixed
*/
function model()
{
return 'Webkul\Core\Models\TaxMap';
}
/**
* @param array $data
* @return mixed
*/
public function create(array $data)
{
$taxMap = $this->model->create($data);
return $taxMap;
}
/**
* @param array $data
* @param $id
* @param string $attribute
* @return mixed
*/
public function update(array $data, $id, $attribute = "id")
{
$taxMap = $this->find($id);
$taxMap->update($data);
return $taxMap;
}
}

View File

@ -0,0 +1,50 @@
<?php
namespace Webkul\Core\Repositories;
use Webkul\Core\Eloquent\Repository;
/**
* Tax Rate Reposotory
*
* @author Prashant Singh <prashant.singh852@webkul.com>
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/
class TaxRateRepository extends Repository
{
/**
* Specify Model class name
*
* @return mixed
*/
function model()
{
return 'Webkul\Core\Models\TaxRate';
}
/**
* @param array $data
* @return mixed
*/
public function create(array $data)
{
$taxRate = $this->model->create($data);
return $taxRate;
}
/**
* @param array $data
* @param $id
* @param string $attribute
* @return mixed
*/
public function update(array $data, $id, $attribute = "id")
{
$taxRate = $this->find($id);
$taxRate->update($data);
return $taxRate;
}
}

View File

@ -0,0 +1,50 @@
<?php
namespace Webkul\Core\Repositories;
use Webkul\Core\Eloquent\Repository;
/**
* Tax Rule Reposotory
*
* @author Prashant Singh <prashant.singh852@webkul.com>
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/
class TaxRuleRepository extends Repository
{
/**
* Specify Model class name
*
* @return mixed
*/
function model()
{
return 'Webkul\Core\Models\TaxRule';
}
/**
* @param array $data
* @return mixed
*/
public function create(array $data)
{
$taxRule = $this->model->create($data);
return $taxRule;
}
/**
* @param array $data
* @param $id
* @param string $attribute
* @return mixed
*/
public function update(array $data, $id, $attribute = "id")
{
$taxRule = $this->find($id);
$taxRule->update($data);
return $taxmap;
}
}

View File

@ -31,12 +31,13 @@ class AccountController extends Controller
public function __construct(CustomerRepository $customer, CustomerAddressRepository $address)
{
$this->middleware('customer');
$this->middleware('auth:customer');
$this->_config = request('_config');
$this->customer = $customer;
$this->address = $address;
$this->customer = $customer;
$this->address = $address;
}
public function index() {

View File

@ -31,15 +31,13 @@ class AddressController extends Controller
public function __construct(CustomerRepository $customer, CustomerAddressRepository $address)
{
$this->middleware('auth:customer');
$this->middleware('customer');
$this->_config = request('_config');
$this->customer = $customer;
$this->address = $address;
}
/**

View File

@ -30,9 +30,11 @@ class CustomerController extends Controller
public function __construct(CustomerRepository $customer)
{
$this->middleware('customer');
$this->_config = request('_config');
$this->customer = $customer;
$this->middleware('auth:customer');
}
/**

View File

@ -29,9 +29,11 @@ class OrdersController extends Controller
public function __construct(CustomerRepository $customer)
{
$this->middleware('customer');
$this->_config = request('_config');
$this->customer = $customer;
$this->middleware('auth:customer');
}
/**

View File

@ -29,9 +29,11 @@ class ReviewsController extends Controller
public function __construct(CustomerRepository $customer)
{
$this->middleware('customer');
$this->_config = request('_config');
$this->customer = $customer;
$this->middleware('auth:customer');
}
/**

View File

@ -24,13 +24,20 @@ class SessionController extends Controller
public function __construct()
{
$this->middleware('customer')->except(['show','create']);
$this->_config = request('_config');
$this->middleware('auth:customer')->except(['show','create']);
}
public function show()
{
return view($this->_config['view']);
if(auth()->guard('customer')->check()) {
return redirect()->route('customer.account.index');
} else {
return view($this->_config['view']);
}
}
public function create(Request $request)
@ -46,7 +53,7 @@ class SessionController extends Controller
return back();
}
return redirect()->route($this->_config['redirect']);
return redirect()->intended(route($this->_config['redirect']));
}
public function destroy($id)
@ -54,4 +61,4 @@ class SessionController extends Controller
auth()->guard('customer')->logout();
return redirect()->route($this->_config['redirect']);
}
}
}

View File

@ -29,9 +29,11 @@ class WishlistController extends Controller
public function __construct(CustomerRepository $customer)
{
$this->middleware('customer');
$this->_config = request('_config');
$this->customer = $customer;
$this->middleware('auth:customer');
}
/**

View File

@ -13,8 +13,6 @@ class CustomerServiceProvider extends ServiceProvider
{
public function boot(Router $router)
{
// include __DIR__ . '/../Http/routes.php';
$this->publishes([
__DIR__ . '/../../publishable/assets' => public_path('vendor/webkul/customer/assets'),
], 'public');

View File

@ -5,6 +5,7 @@ namespace Webkul\Inventory\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Foundation\AliasLoader;
use Illuminate\Routing\Router;
use Webkul\User\Http\Middleware\RedirectIfNotAdmin;
class InventoryServiceProvider extends ServiceProvider
{
@ -15,6 +16,8 @@ class InventoryServiceProvider extends ServiceProvider
*/
public function boot(Router $router)
{
$router->aliasMiddleware('admin', RedirectIfNotAdmin::class);
$this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations');
}

View File

@ -51,8 +51,8 @@ Route::group(['middleware' => ['web']], function () {
//customer account
Route::prefix('account')->group(function () {
Route::get('account/index', 'Webkul\Customer\Http\Controllers\AccountController@index')->defaults('_config', [
'view' => 'shop::customers.account.index'
Route::get('index', 'Webkul\Customer\Http\Controllers\AccountController@index')->defaults('_config', [
'view' => 'shop::customers.account.index'
])->name('customer.account.index');
@ -69,6 +69,7 @@ Route::group(['middleware' => ['web']], function () {
Route::post('profile/edit', 'Webkul\Customer\Http\Controllers\CustomerController@edit')->defaults('_config', [
'view' => 'shop::customers.account.profile.edit'
])->name('customer.profile.edit');
/* Profile Routes Ends Here */

View File

@ -447,13 +447,12 @@ section.slider-block {
margin-right: 10%;
.content-container {
display: inline-block;
width: 100%;
}
.product-grid {
display: grid;
grid-gap: 30px;
grid-gap: 15px;
&.max-2-col {
grid-template-columns: repeat(2, minmax(250px, 1fr));

View File

@ -21,33 +21,34 @@
<a href="{{ route('customer.address.create') }}">Create Address</a>
@else
<table>
<thead>
<tr>
<td>Address 1</td>
<td>Address 2</td>
<td>Country</td>
<td>State</td>
<td>City</td>
<td>Postcode</td>
</tr>
</thead>
<tbody>
<tr>
<td>Address 1</td>
<td>{{ $address['address1'] }}</td>
</tr>
<tr>
<td>Address 2</td>
<td>{{ $address['address2'] }}</td>
</tr>
<tr>
<td>Country</td>
<td>{{ $address['country'] }}</td>
</tr>
<tr>
<td>State</td>
<td>{{ $address['state'] }}</td>
</tr>
<tr>
<td>City</td>
<td>{{ $address['city'] }}</td>
</tr>
<tr>
<td>Postcode</td>
<td>{{ $address['postcode'] }}</td>
</tr>
</tbody>

View File

@ -6,7 +6,7 @@
<ul class="logo-container">
<li>
<a href="">
<a href="{{ route('store.home') }}">
<img class="logo" src="{{ asset('vendor/webkul/shop/assets/images/logo.svg') }}" />
</a>
</li>
@ -74,6 +74,7 @@
<ul>
<li><a href="{{ route('customer.account.index') }}">Account</a></li>
<li><a href="{{ route('customer.profile.index') }}">Profile</a></li>
<li><a href="{{ route('customer.address.index') }}">Address</a></li>
<li><a href="{{ route('customer.wishlist.index') }}">Wishlist</a></li>
<li><a href="{{ route('customer.cart') }}">Cart</a></li>
<li><a href="{{ route('customer.orders.index') }}">Orders</a></li>

View File

@ -617,51 +617,55 @@ class ProductGrid
private function getQueryWithJoin()
{
foreach ($this->join as $join) {
// if(array_key_exists('withAttributes',$join)) {
// $qb = $this->query;
if(array_key_exists('withAttributes',$join)) {
// $channel = $this->channel;
$qb = $this->query;
$channel = $this->channel;
$locale = $this->locale;
// $locale = $this->locale;
foreach ($this->attributeColumns as $code) {
$attribute = $this->attributes->findOneByField('code', $code);
// foreach ($this->attributeColumns as $code) {
$productValueAlias = 'pavxxx' . $attribute->code;
// $attribute = $this->attributes->findOneByField('code', $code);
array_push($this->attributeAliases, $productValueAlias);
// $productValueAlias = 'pav' . $attribute->code;
$qb->leftJoin('product_attribute_values as ' . $productValueAlias, function ($leftJoin) use ($channel, $locale, $attribute, $productValueAlias) {
$leftJoin->on('prods.id', $productValueAlias . '.product_id');
// array_push($this->attributeAliases, $productValueAlias);
if ($attribute->value_per_channel) {
if ($attribute->value_per_locale) {
$leftJoin->where($productValueAlias . '.channel', $channel)->where($productValueAlias . '.locale', $locale);
} else {
$leftJoin->where($productValueAlias . '.channel', $channel);
}
} else {
if ($attribute->value_per_locale) {
$leftJoin->where($productValueAlias . '.locale', $locale);
}
}
// $qb->leftJoin('product_attribute_values as ' . $productValueAlias, function ($leftJoin) use ($channel, $locale, $attribute, $productValueAlias) {
$leftJoin->where($productValueAlias . '.attribute_id', $attribute->id);
});
// $leftJoin->on('prods.id', $productValueAlias . '.product_id');
$qb->addSelect($productValueAlias . '.' . ProductAttributeValue::$attributeTypeFields[$attribute->type] . ' as ' . $code);
}
// if ($attribute->value_per_channel) {
}
else
// if ($attribute->value_per_locale) {
// $leftJoin->where($productValueAlias . '.channel', $channel)->where($productValueAlias . '.locale', $locale);
// } else {
// $leftJoin->where($productValueAlias . '.channel', $channel);
// }
// } else {
// if ($attribute->value_per_locale) {
// $leftJoin->where($productValueAlias . '.locale', $locale);
// }
// }
// $leftJoin->where($productValueAlias . '.attribute_id', $attribute->id);
// });
// $qb->addSelect($productValueAlias . '.' . ProductAttributeValue::$attributeTypeFields[$attribute->type] . ' as ' . $code);
// }
// }
// else
$this->query->{$join['join']}($join['table'], $join['primaryKey'], $join['condition'], $join['secondaryKey']);
}
// dd($this->query->toSql());
$this->query->get();
}
/**

View File

@ -9,30 +9,49 @@
{{-- Section for datagrid javascript --}}
@push('scripts')
<script type="text/javascript">
var columns = @json($columns); //referential
var allFilters = [];
var search_value;
var filter_column;
var filter_condition;
var filter_range;
var count_filters = parseInt(0);
var url;
var array_start = '[';
var array_end = ']';
var typeValue;
var selectedColumn = '';
var myURL = document.location;
let params;
$(document).ready(function() {
params = (new URL(document.location)).search;
if(params.length>0) {
if(allFilters.length == 0) {
//call reverse url function
arrayFromUrl(params.slice(1,params.length));
}
}
$('.search-btn').click(function() {
search_value = $(".search-field").val();
formURL('search','all',search_value,params); //format for search
});
@ -46,33 +65,47 @@
if(currentSort == "asc")
formURL("sort",column,"desc",params);
else if(currentSort == "desc")
formURL("sort",column,"asc",params);
});
$('select.filter-column-select').change(function() {
typeValue = $('select.filter-column-select').find(':selected').data('type');
col_label = $('select.filter-column-select').find(':selected').data('label');
selectedColumn = $('select.filter-column-select').find(':selected').val();
if(typeValue == 'string') {
//default behaviour for strings
$('.filter-condition-dropdown-number').css('display','none');
$('.filter-condition-dropdown-datetime').css('display','none');
$('.filter-response-number').css('display','none');
$('.filter-response-datetime').css('display','none');
$('.filter-response-boolean').css('display','none');
//show the two wanted
$('.filter-condition-dropdown-string').css('display','inherit');
$('.filter-response-string').css('display','inherit');
}
else if(typeValue == 'boolean') {
//hide unwanted
$('.filter-condition-dropdown-string').css('display','none');
$('.filter-condition-dropdown-number').css('display','none');
$('.filter-condition-dropdown-datetime').css('display','none');
$('.filter-response-string').css('display','none');
$('.filter-response-number').css('display','none');
$('.filter-response-datetime').css('display','none');
//only true or false for that column is needed as input
@ -81,25 +114,35 @@
else if(typeValue == 'datetime') {
//hide unwanted
$('.filter-condition-dropdown-string').css('display','none');
$('.filter-condition-dropdown-number').css('display','none');
$('.filter-response-string').css('display','none');
$('.filter-response-number').css('display','none');
$('.filter-response-boolean').css('display','none');
//show what is wanted
$('.filter-condition-dropdown-datetime').css('display','inherit');
$('.filter-response-datetime').css('display','inherit');
}
else if(typeValue == 'number') {
//hide unwanted
$('.filter-condition-dropdown-string').css('display','none');
$('.filter-condition-dropdown-datetime').css('display','none');
$('.filter-response-string').css('display','none');
$('.filter-response-datetime').css('display','none');
$('.filter-response-boolean').css('display','none');
//show what is wanted
$('.filter-condition-dropdown-number').css('display','inherit');
$('.filter-response-number').css('display','inherit');
}
@ -111,20 +154,26 @@
if(typeValue == 'number') {
var conditionUsed = $('.filter-condition-dropdown-number').find(':selected').val();
var response = $('.response-number').val();
formURL(selectedColumn,conditionUsed,response,params,col_label);
}
if(typeValue == 'string') {
var conditionUsed = $('.filter-condition-dropdown-string').find(':selected').val();
var response = $('.response-string').val();
formURL(selectedColumn,conditionUsed,response,params,col_label);
}
if(typeValue == 'datetime') {
var conditionUsed = $('.filter-condition-dropdown-datetime').find(':selected').val();
var response = $('.response-datetime').val();
formURL(selectedColumn,conditionUsed,response,params,col_label);
}
if(typeValue == 'boolean') { //use select dropdown with two values true and false
@ -222,7 +271,9 @@
if(id.length>0) {
$('.mass-action').css('display','');
$('.table-grid-header').css('display','none');
$('#indexes').val(id);
}else if(id.length == 0) {
@ -363,11 +414,15 @@
/* validate the conditions here and do the replacements and
push here in the all filters array */
var obj1 = {};
console.log(allFilters.length);
if(column == "" || condition == "" || response == "") {
alert("Some of the required field is null, please check column, condition and value properly.");
return false;
}
else {
@ -378,29 +433,38 @@
filter_repeated = 0;
for(j=0;j<allFilters.length;j++) {
for(j=0; j<allFilters.length; j++) {
if(allFilters[j].column == column && allFilters[j].cond == condition && allFilters[j].val == response)
{
filter_repeated = 1;
return false;
} else if(allFilters[j].column == column) {
filter_repeated = 1;
allFilters[j].cond = condition;
allFilters[j].val = response;
makeURL(true);
allFilters[j].cond = condition;
allFilters[j].val = response;
makeURL(true);
}
}
if(filter_repeated == 0) {
obj1.column = column;
obj1.cond = condition;
obj1.val = response;
obj1.label = clabel;
allFilters.push(obj1);
obj1 = {};
makeURL();
}
}
@ -417,18 +481,26 @@
if(response=="asc") {
allFilters[j].column = column;
allFilters[j].cond = condition;
allFilters[j].val = "desc";
allFilters[j].label = clabel;
makeURL();
}
else {
allFilters[j].column = column;
allFilters[j].cond = condition;
allFilters[j].val = "asc";
allFilters[j].label = clabel;
makeURL();
}
@ -437,9 +509,13 @@
else {
allFilters[j].column = column;
allFilters[j].cond = condition;
allFilters[j].val = response;
allFilters[j].label = clabel;
makeURL();
}
@ -455,6 +531,7 @@
for(j=0;j<allFilters.length;j++) {
if(allFilters[j].column == "search") {
allFilters[j].column = column;
allFilters[j].cond = condition;
allFilters[j].val = response;
@ -482,18 +559,24 @@
} else {
obj1.column = column;
obj1.cond = condition;
obj1.val = response;
obj1.label = clabel;
allFilters.push(obj1);
obj1 = {};
makeURL();
}
}
}
function confirm_click(x){
if (confirm(x)) {
function confirm_click(message){
if (confirm(message)) {
} else {
return false;

View File

@ -106,7 +106,7 @@
<th class="grid_head" data-column-name="{{ $column->alias }}" data-column-label="{{ $column->label }}">{!! $column->sorting() !!}</th>
@endif
@endforeach
@if(isset($attribute_columns))
{{-- @if(isset($attribute_columns))
@foreach($attribute_columns as $key => $value)
<th class="grid_head"
data-column-name="{{ $attributeAliases[$key] }}"
@ -116,7 +116,7 @@
{{ $value }}<span class="icon sort-down-icon"></span>
</th>
@endforeach
@endif
@endif --}}
<th>
Actions
</th>
@ -135,12 +135,11 @@
@foreach ($columns as $column)
<td class="">{!! $column->render($result) !!}</td>
@endforeach
@if(isset($attribute_columns))
{{-- @if(isset($attribute_columns))
@foreach ($attribute_columns as $atc)
<td>{{ $result->{$atc} }}</td>
@endforeach
@endif
@endif --}}
<td class="action">
@foreach($actions as $action)

View File

@ -24,6 +24,8 @@ class AccountController extends Controller
*/
public function __construct()
{
$this->middleware('admin');
$this->_config = request('_config');
}
@ -53,7 +55,7 @@ class AccountController extends Controller
'email' => 'email|unique:admins,email,' . $user->id,
'password' => 'nullable|confirmed'
]);
$user->update(request(['name', 'email', 'password']));

View File

@ -20,7 +20,7 @@ class RoleController extends Controller
* @var array
*/
protected $_config;
/**
* RoleRepository object
*
@ -36,6 +36,8 @@ class RoleController extends Controller
*/
public function __construct(Role $role)
{
$this->middleware('admin');
$this->role = $role;
$this->_config = request('_config');
@ -107,7 +109,7 @@ class RoleController extends Controller
'name' => 'required',
'permission_type' => 'required',
]);
$this->role->update(request()->all(), $id);
session()->flash('success', 'Role updated successfully.');

View File

@ -4,6 +4,7 @@ namespace Webkul\User\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Auth;
/**
* Admin user session controller
@ -27,6 +28,8 @@ class SessionController extends Controller
*/
public function __construct()
{
$this->middleware('admin')->except(['create','store']);
$this->_config = request('_config');
$this->middleware('guest', ['except' => 'destroy']);
@ -39,7 +42,12 @@ class SessionController extends Controller
*/
public function create()
{
return view($this->_config['view']);
if (auth()->guard('admin')->check()) {
return redirect()->route('admin.dashboard.index');
} else {
return view($this->_config['view']);
}
}
/**
@ -61,7 +69,7 @@ class SessionController extends Controller
return back();
}
return redirect()->route($this->_config['redirect']);
return redirect()->intended(route($this->_config['redirect']));
}
/**

View File

@ -22,14 +22,14 @@ class UserController extends Controller
* @var array
*/
protected $_config;
/**
* AdminRepository object
*
* @var array
*/
protected $admin;
/**
* RoleRepository object
*
@ -46,6 +46,8 @@ class UserController extends Controller
*/
public function __construct(Admin $admin, Role $role)
{
$this->middleware('admin');
$this->admin = $admin;
$this->role = $role;

View File

@ -518,13 +518,12 @@ section.slider-block div.slider-content div.slider-control .light-right-icon {
}
.main-container-wrapper .content-container {
display: inline-block;
width: 100%;
}
.main-container-wrapper .product-grid {
display: grid;
grid-gap: 30px;
grid-gap: 15px;
}
.main-container-wrapper .product-grid.max-2-col {