datagrid's configuration dependency is removed and dynamic row format is back
This commit is contained in:
parent
f0d600d510
commit
e2037c4892
|
|
@ -50,8 +50,8 @@ return [
|
|||
'charset' => 'utf8mb4',
|
||||
'collation' => 'utf8mb4_unicode_ci',
|
||||
'prefix' => '',
|
||||
'strict' => true,
|
||||
'engine' => null,
|
||||
'strict' => false,
|
||||
'engine' => 'InnoDB ROW_FORMAT=DYNAMIC',
|
||||
],
|
||||
|
||||
'pgsql' => [
|
||||
|
|
|
|||
|
|
@ -1,90 +0,0 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/**
|
||||
* Default Select Value
|
||||
*/
|
||||
'default_index' => '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"
|
||||
]
|
||||
];
|
||||
|
|
@ -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')
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\Admin\Listeners;
|
||||
|
||||
|
||||
/**
|
||||
* Products Flat Event handler
|
||||
*
|
||||
* @author Prashant Singh <prashant.singh852@webkul.com> @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');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\Product\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
|
||||
class EventServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Bootstrap services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
Event::listen('after.attribute.update', 'Webkul\Product\Listeners\ProductFlat@afterAttributeUpdated');
|
||||
}
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@
|
|||
namespace Webkul\Product\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Webkul\Product\Providers\EventServiceProvider;
|
||||
use Illuminate\Routing\Router;
|
||||
use Webkul\Product\Models\Product;
|
||||
|
||||
|
|
@ -16,6 +17,8 @@ class ProductServiceProvider extends ServiceProvider
|
|||
public function boot(Router $router)
|
||||
{
|
||||
$this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations');
|
||||
|
||||
$this->app->register(EventServiceProvider::class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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')]);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
<div class="table">
|
||||
<datagrid-filters></datagrid-filters>
|
||||
|
||||
@if (config('datagrid.paginate'))
|
||||
@if (isset($results['paginated']) && $results['paginated'])
|
||||
@include('ui::datagrid.pagination', ['results' => $results['records']])
|
||||
@endif
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue