diff --git a/config/database.php b/config/database.php index cab5d068f..71280b1b1 100755 --- a/config/database.php +++ b/config/database.php @@ -50,8 +50,8 @@ return [ 'charset' => 'utf8mb4', 'collation' => 'utf8mb4_unicode_ci', 'prefix' => '', - 'strict' => true, - 'engine' => null, + 'strict' => false, + 'engine' => 'InnoDB ROW_FORMAT=DYNAMIC', ], 'pgsql' => [ diff --git a/config/datagrid.php b/config/datagrid.php deleted file mode 100644 index 44fd576ba..000000000 --- a/config/datagrid.php +++ /dev/null @@ -1,90 +0,0 @@ - 'id', - - /** - * Default OrderBy - * - * * Accepted Values = Array - */ - 'order' => [ - 'default' => 'descending', - 'descending' => 'desc', - 'ascending' => 'asc' - ], - - /** - * Select distinct records only - * - * Accepted Values = True || False - */ - 'distinct' => true, - - /** - * Default pagination - * - * Accepted Value = integer - */ - 'paginate' => true, - - 'operators' => [ - 'eq' => "=", - 'lt' => "<", - 'gt' => ">", - 'lte' => "<=", - 'gte' => ">=", - 'neqs' => "<>", - 'neqn' => "!=", - 'eqo' => "<=>", - 'like' => "like", - 'blike' => "like binary", - 'nlike' => "not like", - 'ilike' => "ilike", - 'and' => "&", - 'bor' => "|", - 'regex' => "regexp", - 'notregex' => "not regexp", - // 14 => "^", - // 15 => "<<", - // 16 => ">>", - // 17 => "rlike", - // 20 => "~", - // 21 => "~*", - // 22 => "!~", - // 23 => "!~*", - // 24 => "similar to", - // 25 => "not similar to", - // 26 => "not ilike", - // 27 => "~~*", - // 28 => "!~~*" - ], - - 'bindings' => [ - 0 => "select", - 1 => "from", - 2 => "join", - 3 => "where", - 4 => "having", - 5 => "order", - 6 => "union" - ], - - 'selectcomponents' => [ - 0 => "aggregate", - 1 => "columns", - 2 => "from", - 3 => "joins", - 4 => "wheres", - 5 => "groups", - 6 => "havings", - 7 => "orders", - 8 => "limit", - 9 => "offset", - 10 => "lock" - ] -]; \ No newline at end of file diff --git a/packages/Webkul/Admin/src/DataGrids/AttributeDataGrid.php b/packages/Webkul/Admin/src/DataGrids/AttributeDataGrid.php index 9875ed3f1..6e0be521b 100755 --- a/packages/Webkul/Admin/src/DataGrids/AttributeDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/AttributeDataGrid.php @@ -13,11 +13,12 @@ use DB; */ class AttributeDataGrid extends DataGrid { - protected $itemsPerPage = 5; //overriding the default items per page + protected $paginate = true; + + protected $itemsPerPage = 10; //overriding the default items per page protected $index = 'id'; //the column that needs to be treated as index column - public function prepareQueryBuilder() { $queryBuilder = DB::table('attributes') diff --git a/packages/Webkul/Admin/src/DataGrids/AttributeFamilyDataGrid.php b/packages/Webkul/Admin/src/DataGrids/AttributeFamilyDataGrid.php index b531b1bd6..a0b8ef476 100755 --- a/packages/Webkul/Admin/src/DataGrids/AttributeFamilyDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/AttributeFamilyDataGrid.php @@ -13,7 +13,9 @@ use DB; */ class AttributeFamilyDataGrid extends DataGrid { - protected $itemsPerPage = 5; + protected $paginate = true; + + protected $itemsPerPage = 5; //overriding the default items per page protected $index = 'id'; //the column that needs to be treated as index column diff --git a/packages/Webkul/Admin/src/DataGrids/CategoryDataGrid.php b/packages/Webkul/Admin/src/DataGrids/CategoryDataGrid.php index 7d8263c98..c7ca02e66 100755 --- a/packages/Webkul/Admin/src/DataGrids/CategoryDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/CategoryDataGrid.php @@ -13,6 +13,10 @@ use DB; */ class CategoryDataGrid extends DataGrid { + protected $paginate = true; + + protected $itemsPerPage = 5; //overriding the default items per page + protected $index = 'category_id'; //the column that needs to be treated as index column public function prepareQueryBuilder() diff --git a/packages/Webkul/Admin/src/DataGrids/ChannelDataGrid.php b/packages/Webkul/Admin/src/DataGrids/ChannelDataGrid.php index 4c25f82da..55afd1c5b 100755 --- a/packages/Webkul/Admin/src/DataGrids/ChannelDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/ChannelDataGrid.php @@ -13,6 +13,10 @@ use DB; */ class ChannelDataGrid extends DataGrid { + protected $paginate = true; + + protected $itemsPerPage = 5; //overriding the default items per page + protected $index = 'id'; //the column that needs to be treated as index column public function prepareQueryBuilder() diff --git a/packages/Webkul/Admin/src/DataGrids/CurrencyDataGrid.php b/packages/Webkul/Admin/src/DataGrids/CurrencyDataGrid.php index 02652f0b1..6d806750d 100755 --- a/packages/Webkul/Admin/src/DataGrids/CurrencyDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/CurrencyDataGrid.php @@ -13,6 +13,10 @@ use DB; */ class CurrencyDataGrid extends DataGrid { + protected $paginate = true; + + protected $itemsPerPage = 5; //overriding the default items per page + protected $index = 'id'; //the column that needs to be treated as index column public function prepareQueryBuilder() diff --git a/packages/Webkul/Admin/src/DataGrids/CustomerDataGrid.php b/packages/Webkul/Admin/src/DataGrids/CustomerDataGrid.php index 919959b32..e13c99cd6 100755 --- a/packages/Webkul/Admin/src/DataGrids/CustomerDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/CustomerDataGrid.php @@ -13,7 +13,9 @@ use DB; */ class CustomerDataGrid extends DataGrid { - protected $itemsPerPage = 5; + protected $paginate = true; + + protected $itemsPerPage = 5; //overriding the default items per page protected $index = 'customer_id'; //the column that needs to be treated as index column diff --git a/packages/Webkul/Admin/src/DataGrids/CustomerGroupDataGrid.php b/packages/Webkul/Admin/src/DataGrids/CustomerGroupDataGrid.php index 746333d90..b3c26187f 100755 --- a/packages/Webkul/Admin/src/DataGrids/CustomerGroupDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/CustomerGroupDataGrid.php @@ -13,6 +13,10 @@ use DB; */ class CustomerGroupDataGrid extends DataGrid { + protected $paginate = true; + + protected $itemsPerPage = 5; //overriding the default items per page + protected $index = 'id'; //the column that needs to be treated as index column public function prepareQueryBuilder() diff --git a/packages/Webkul/Admin/src/DataGrids/CustomerReviewDataGrid.php b/packages/Webkul/Admin/src/DataGrids/CustomerReviewDataGrid.php index 021d1da99..e5ff12be7 100755 --- a/packages/Webkul/Admin/src/DataGrids/CustomerReviewDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/CustomerReviewDataGrid.php @@ -13,7 +13,11 @@ use DB; */ class CustomerReviewDataGrid extends DataGrid { - protected $index = 'product_review_id'; //the column that needs to be treated as index column + protected $paginate = true; + + protected $itemsPerPage = 5; //overriding the default items per page + + protected $index = 'product_review_id'; //column that needs to be treated as index column public function prepareQueryBuilder() { diff --git a/packages/Webkul/Admin/src/DataGrids/ExchangeRatesDataGrid.php b/packages/Webkul/Admin/src/DataGrids/ExchangeRatesDataGrid.php index b6e4b33a1..d814b168a 100755 --- a/packages/Webkul/Admin/src/DataGrids/ExchangeRatesDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/ExchangeRatesDataGrid.php @@ -13,6 +13,10 @@ use DB; */ class ExchangeRatesDataGrid extends DataGrid { + protected $paginate = true; + + protected $itemsPerPage = 5; //overriding the default items per page + protected $index = 'currency_exch_id'; public function prepareQueryBuilder() diff --git a/packages/Webkul/Admin/src/DataGrids/InventorySourcesDataGrid.php b/packages/Webkul/Admin/src/DataGrids/InventorySourcesDataGrid.php index 14bf2f630..90a7d871b 100755 --- a/packages/Webkul/Admin/src/DataGrids/InventorySourcesDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/InventorySourcesDataGrid.php @@ -13,6 +13,10 @@ use DB; */ class InventorySourcesDataGrid extends DataGrid { + protected $paginate = true; + + protected $itemsPerPage = 5; //overriding the default items per page + protected $index = 'id'; public function prepareQueryBuilder() diff --git a/packages/Webkul/Admin/src/DataGrids/LocalesDataGrid.php b/packages/Webkul/Admin/src/DataGrids/LocalesDataGrid.php index 09900efbe..f8bdbec51 100755 --- a/packages/Webkul/Admin/src/DataGrids/LocalesDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/LocalesDataGrid.php @@ -13,6 +13,10 @@ use DB; */ class LocalesDataGrid extends DataGrid { + protected $paginate = true; + + protected $itemsPerPage = 5; //overriding the default items per page + protected $index = 'id'; public function prepareQueryBuilder() diff --git a/packages/Webkul/Admin/src/DataGrids/NewsLetterDataGrid.php b/packages/Webkul/Admin/src/DataGrids/NewsLetterDataGrid.php index 462f1e715..6790601c1 100755 --- a/packages/Webkul/Admin/src/DataGrids/NewsLetterDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/NewsLetterDataGrid.php @@ -13,6 +13,10 @@ use DB; */ class NewsLetterDataGrid extends DataGrid { + protected $paginate = true; + + protected $itemsPerPage = 5; //overriding the default items per page + protected $index = 'id'; public function prepareQueryBuilder() diff --git a/packages/Webkul/Admin/src/DataGrids/OrderDataGrid.php b/packages/Webkul/Admin/src/DataGrids/OrderDataGrid.php index d87598706..13d1d8499 100755 --- a/packages/Webkul/Admin/src/DataGrids/OrderDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/OrderDataGrid.php @@ -13,6 +13,10 @@ use DB; */ class OrderDataGrid extends DataGrid { + protected $paginate = true; + + protected $itemsPerPage = 5; //overriding the default items per page + protected $index = 'id'; public function prepareQueryBuilder() diff --git a/packages/Webkul/Admin/src/DataGrids/OrderInvoicesDataGrid.php b/packages/Webkul/Admin/src/DataGrids/OrderInvoicesDataGrid.php index bc1c5f1f2..42751f6a8 100755 --- a/packages/Webkul/Admin/src/DataGrids/OrderInvoicesDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/OrderInvoicesDataGrid.php @@ -13,6 +13,10 @@ use DB; */ class OrderInvoicesDataGrid extends DataGrid { + protected $paginate = true; + + protected $itemsPerPage = 5; //overriding the default items per page + protected $index = 'id'; public function prepareQueryBuilder() diff --git a/packages/Webkul/Admin/src/DataGrids/OrderShipmentsDataGrid.php b/packages/Webkul/Admin/src/DataGrids/OrderShipmentsDataGrid.php index 3049b6782..32d53b0a7 100755 --- a/packages/Webkul/Admin/src/DataGrids/OrderShipmentsDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/OrderShipmentsDataGrid.php @@ -13,6 +13,10 @@ use DB; */ class OrderShipmentsDataGrid extends DataGrid { + protected $paginate = true; + + protected $itemsPerPage = 5; //overriding the default items per page + protected $index = 'shipment_id'; public function prepareQueryBuilder() diff --git a/packages/Webkul/Admin/src/DataGrids/ProductDataGrid.php b/packages/Webkul/Admin/src/DataGrids/ProductDataGrid.php index 2b2795986..9a656e0fd 100644 --- a/packages/Webkul/Admin/src/DataGrids/ProductDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/ProductDataGrid.php @@ -13,6 +13,10 @@ use DB; */ class ProductDataGrid extends DataGrid { + protected $paginate = true; + + protected $itemsPerPage = 5; //overriding the default items per page + protected $index = 'product_id'; public function prepareQueryBuilder() diff --git a/packages/Webkul/Admin/src/DataGrids/RolesDataGrid.php b/packages/Webkul/Admin/src/DataGrids/RolesDataGrid.php index 88814b9f1..4fcafeaf4 100755 --- a/packages/Webkul/Admin/src/DataGrids/RolesDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/RolesDataGrid.php @@ -13,6 +13,10 @@ use DB; */ class RolesDataGrid extends DataGrid { + protected $paginate = true; + + protected $itemsPerPage = 5; //overriding the default items per page + protected $index = 'id'; public function prepareQueryBuilder() diff --git a/packages/Webkul/Admin/src/DataGrids/SliderDataGrid.php b/packages/Webkul/Admin/src/DataGrids/SliderDataGrid.php index 3de2579bd..c2ef757a2 100755 --- a/packages/Webkul/Admin/src/DataGrids/SliderDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/SliderDataGrid.php @@ -13,6 +13,10 @@ use DB; */ class SliderDataGrid extends DataGrid { + protected $paginate = true; + + protected $itemsPerPage = 5; //overriding the default items per page + protected $index = 'slider_id'; public function prepareQueryBuilder() diff --git a/packages/Webkul/Admin/src/DataGrids/TaxCategoryDataGrid.php b/packages/Webkul/Admin/src/DataGrids/TaxCategoryDataGrid.php index 0098a80e6..e646180f3 100755 --- a/packages/Webkul/Admin/src/DataGrids/TaxCategoryDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/TaxCategoryDataGrid.php @@ -13,6 +13,10 @@ use DB; */ class TaxCategoryDataGrid extends DataGrid { + protected $paginate = true; + + protected $itemsPerPage = 5; //overriding the default items per page + protected $index = 'id'; public function prepareQueryBuilder() diff --git a/packages/Webkul/Admin/src/DataGrids/TaxRateDataGrid.php b/packages/Webkul/Admin/src/DataGrids/TaxRateDataGrid.php index 7beca667c..b568ac58e 100755 --- a/packages/Webkul/Admin/src/DataGrids/TaxRateDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/TaxRateDataGrid.php @@ -13,6 +13,10 @@ use DB; */ class TaxRateDataGrid extends DataGrid { + protected $paginate = true; + + protected $itemsPerPage = 5; //overriding the default items per page + protected $index = 'id'; public function prepareQueryBuilder() diff --git a/packages/Webkul/Admin/src/DataGrids/UserDataGrid.php b/packages/Webkul/Admin/src/DataGrids/UserDataGrid.php index dc1477e11..76818aed6 100755 --- a/packages/Webkul/Admin/src/DataGrids/UserDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/UserDataGrid.php @@ -13,6 +13,10 @@ use DB; */ class UserDataGrid extends DataGrid { + protected $paginate = true; + + protected $itemsPerPage = 5; //overriding the default items per page + protected $index = 'user_id'; public function prepareQueryBuilder() diff --git a/packages/Webkul/Attribute/src/Http/Controllers/AttributeController.php b/packages/Webkul/Attribute/src/Http/Controllers/AttributeController.php index afdd4af03..9e0b4fe2f 100755 --- a/packages/Webkul/Attribute/src/Http/Controllers/AttributeController.php +++ b/packages/Webkul/Attribute/src/Http/Controllers/AttributeController.php @@ -5,7 +5,7 @@ namespace Webkul\Attribute\Http\Controllers; use Illuminate\Http\Request; use Illuminate\Http\Response; use Webkul\Attribute\Repositories\AttributeRepository as Attribute; - +// use Event; /** * Catalog attribute controller diff --git a/packages/Webkul/Product/src/Listeners/ProductFlat.php b/packages/Webkul/Product/src/Listeners/ProductFlat.php new file mode 100644 index 000000000..4dc0ae869 --- /dev/null +++ b/packages/Webkul/Product/src/Listeners/ProductFlat.php @@ -0,0 +1,24 @@ + @prashant-webkul + * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) + */ +class ProductFlat { + + /** + * After the attribute is updated + * + * @return void + */ + public function afterAttributeUpdated() + { + dd('after attribute is created'); + } + +} \ No newline at end of file diff --git a/packages/Webkul/Product/src/Providers/EventServiceProvider.php b/packages/Webkul/Product/src/Providers/EventServiceProvider.php new file mode 100644 index 000000000..4059bec16 --- /dev/null +++ b/packages/Webkul/Product/src/Providers/EventServiceProvider.php @@ -0,0 +1,19 @@ +loadMigrationsFrom(__DIR__ . '/../Database/Migrations'); + + $this->app->register(EventServiceProvider::class); } /** diff --git a/packages/Webkul/Ui/src/DataGrid/DataGrid.php b/packages/Webkul/Ui/src/DataGrid/DataGrid.php index 5afcc73f2..0bcd3a4de 100644 --- a/packages/Webkul/Ui/src/DataGrid/DataGrid.php +++ b/packages/Webkul/Ui/src/DataGrid/DataGrid.php @@ -25,7 +25,63 @@ abstract class DataGrid protected $parse; protected $enableMassAction = false; protected $enableAction = false; + protected $paginate = false; protected $itemsPerPage = 10; + protected $operators = [ + 'eq' => "=", + 'lt' => "<", + 'gt' => ">", + 'lte' => "<=", + 'gte' => ">=", + 'neqs' => "<>", + 'neqn' => "!=", + 'eqo' => "<=>", + 'like' => "like", + 'blike' => "like binary", + 'nlike' => "not like", + 'ilike' => "ilike", + 'and' => "&", + 'bor' => "|", + 'regex' => "regexp", + 'notregex' => "not regexp", + // 14 => "^", + // 15 => "<<", + // 16 => ">>", + // 17 => "rlike", + // 20 => "~", + // 21 => "~*", + // 22 => "!~", + // 23 => "!~*", + // 24 => "similar to", + // 25 => "not similar to", + // 26 => "not ilike", + // 27 => "~~*", + // 28 => "!~~*" + ]; + + protected $bindings = [ + 0 => "select", + 1 => "from", + 2 => "join", + 3 => "where", + 4 => "having", + 5 => "order", + 6 => "union" + ]; + + protected $selectcomponents = [ + 0 => "aggregate", + 1 => "columns", + 2 => "from", + 3 => "joins", + 4 => "wheres", + 5 => "groups", + 6 => "havings", + 7 => "orders", + 8 => "limit", + 9 => "offset", + 10 => "lock" + ]; abstract public function prepareQueryBuilder(); abstract public function addColumns(); @@ -97,7 +153,7 @@ abstract class DataGrid if (count($parsedUrl)) { $filteredOrSortedCollection = $this->sortOrFilterCollection($this->collection = $this->queryBuilder, $parsedUrl); - if (config('datagrid.paginate')) { + if ($this->paginate) { if ($this->itemsPerPage > 0) return $filteredOrSortedCollection->paginate($this->itemsPerPage)->appends(request()->except('page')); } else { @@ -105,7 +161,7 @@ abstract class DataGrid } } - if (config('datagrid.paginate')) { + if ($this->paginate) { if ($this->itemsPerPage > 0) { $this->collection = $this->queryBuilder->paginate($this->itemsPerPage)->appends(request()->except('page')); } @@ -176,13 +232,13 @@ abstract class DataGrid if ($this->enableFilterMap && isset($this->filterMap[$columnName])) { $collection->where( $this->filterMap[$columnName], - config("datagrid.operators.{$condition}"), + $this->operators[$condition], '%'.$filter_value.'%' ); } else { $collection->where( $columnName, - config("datagrid.operators.{$condition}"), + $this->operators[$condition], '%'.$filter_value.'%' ); } @@ -193,13 +249,13 @@ abstract class DataGrid if ($this->enableFilterMap && isset($this->filterMap[$columnName])) { $collection->whereDate( $this->filterMap[$columnName], - config("datagrid.operators.{$condition}"), + $this->operators[$condition], $filter_value ); } else { $collection->whereDate( $columnName, - config("datagrid.operators.{$condition}"), + $this->operators[$condition], $filter_value ); } @@ -207,13 +263,13 @@ abstract class DataGrid if ($this->enableFilterMap && isset($this->filterMap[$columnName])) { $collection->where( $this->filterMap[$columnName], - config("datagrid.operators.{$condition}"), + $this->operators[$condition], $filter_value ); } else { $collection->where( $columnName, - config("datagrid.operators.{$condition}"), + $this->operators[$condition], $filter_value ); } @@ -222,7 +278,7 @@ abstract class DataGrid } } } - // dd($collection->toSql()); + return $collection; } @@ -242,6 +298,8 @@ abstract class DataGrid $this->prepareQueryBuilder(); - return view('ui::datagrid.table')->with('results', ['records' => $this->getCollection(), 'columns' => $this->completeColumnDetails, 'actions' => $this->actions, 'massactions' => $this->massActions, 'index' => $this->index, 'enableMassActions' => $this->enableMassAction, 'enableActions' => $this->enableAction, 'norecords' => trans('ui::app.datagrid.no-records')]); + // dd($this->paginate, $this->itemsPerPage); + + return view('ui::datagrid.table')->with('results', ['records' => $this->getCollection(), 'columns' => $this->completeColumnDetails, 'actions' => $this->actions, 'massactions' => $this->massActions, 'index' => $this->index, 'enableMassActions' => $this->enableMassAction, 'enableActions' => $this->enableAction, 'paginated' => $this->paginate, 'norecords' => trans('ui::app.datagrid.no-records')]); } } \ No newline at end of file diff --git a/packages/Webkul/Ui/src/Resources/views/datagrid/table.blade.php b/packages/Webkul/Ui/src/Resources/views/datagrid/table.blade.php index cc681b4cb..7491fdf21 100644 --- a/packages/Webkul/Ui/src/Resources/views/datagrid/table.blade.php +++ b/packages/Webkul/Ui/src/Resources/views/datagrid/table.blade.php @@ -1,7 +1,7 @@
- @if (config('datagrid.paginate')) + @if (isset($results['paginated']) && $results['paginated']) @include('ui::datagrid.pagination', ['results' => $results['records']]) @endif