diff --git a/README.md b/README.md index 19d581197..404a12870 100755 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ Bagisto is using power of both of these frameworks and making best out of it out **Run this Command** to download the project on to your local machine or server: ->> Note: If you have downloaded zip file then ignore this. +> Note: If you have downloaded zip file then ignore this. ~~~ composer create-project bagisto/bagisto @@ -89,12 +89,12 @@ default. **Run these Commands Below** ->> Run this command, in case installing from the zip else skip this command (no need to run this command if you are creating project through composer): +> Run this command, in case installing from the zip else skip this command (no need to run this command if you are creating project through composer): ~~~ composer install ~~~ ->> Continue run these command below: +> Continue run these command below: ~~~ php artisan migrate ~~~ diff --git a/config/datagrid.php b/config/datagrid.php index 6d9b1da1b..aeaf51a57 100644 --- a/config/datagrid.php +++ b/config/datagrid.php @@ -5,7 +5,7 @@ return [ /** * Default Select Value */ - 'select' => 'id', + 'default_index' => 'id', /** * Default OrderBy @@ -30,7 +30,7 @@ return [ * * Accepted Value = integer */ - 'pagination' => 10, + 'paginate' => false, 'operators' => [ 'eq' => "=", diff --git a/packages/Webkul/Admin/src/DataGrids/AttributeDataGrid.php b/packages/Webkul/Admin/src/DataGrids/AttributeDataGrid.php index f45534b51..029bf80b4 100755 --- a/packages/Webkul/Admin/src/DataGrids/AttributeDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/AttributeDataGrid.php @@ -6,19 +6,17 @@ use Webkul\Ui\DataGrid\DataGrid; use DB; /** - * Product Data Grid class + * AttributeDataGrid class * * @author Prashant Singh @prashant-webkul * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) */ class AttributeDataGrid extends DataGrid { - public $allColumns = []; + protected $itemsPerPage = 5; //overriding the default items per page + + protected $index = 'id'; //the column that needs to be treated as index column - public function __construct() - { - $this->itemsPerPage = 10; - } public function prepareQueryBuilder() { @@ -27,17 +25,11 @@ class AttributeDataGrid extends DataGrid $this->setQueryBuilder($queryBuilder); } - public function setIndex() - { - $this->index = 'id'; //the column that needs to be treated as index column - } - public function addColumns() { $this->addColumn([ 'index' => 'id', - 'alias' => 'attributeId', - 'label' => 'ID', + 'label' => trans('admin::app.datagrid.id'), 'type' => 'number', 'searchable' => false, 'sortable' => true, @@ -46,8 +38,7 @@ class AttributeDataGrid extends DataGrid $this->addColumn([ 'index' => 'code', - 'alias' => 'attributeCode', - 'label' => 'Code', + 'label' => trans('admin::app.datagrid.code'), 'type' => 'string', 'searchable' => true, 'sortable' => true, @@ -56,8 +47,7 @@ class AttributeDataGrid extends DataGrid $this->addColumn([ 'index' => 'admin_name', - 'alias' => 'attributeAdminName', - 'label' => 'Name', + 'label' => trans('admin::app.datagrid.admin-name'), 'type' => 'string', 'searchable' => true, 'sortable' => true, @@ -66,8 +56,7 @@ class AttributeDataGrid extends DataGrid $this->addColumn([ 'index' => 'type', - 'alias' => 'attributeType', - 'label' => 'Type', + 'label' => trans('admin::app.datagrid.type'), 'type' => 'string', 'sortable' => true, 'searchable' => true, @@ -76,8 +65,7 @@ class AttributeDataGrid extends DataGrid $this->addColumn([ 'index' => 'is_required', - 'alias' => 'attributeRequired', - 'label' => 'Required', + 'label' => trans('admin::app.datagrid.required'), 'type' => 'boolean', 'sortable' => true, 'searchable' => false, @@ -92,8 +80,7 @@ class AttributeDataGrid extends DataGrid $this->addColumn([ 'index' => 'is_unique', - 'alias' => 'attributeIsUnique', - 'label' => 'Unique', + 'label' => trans('admin::app.datagrid.unique'), 'type' => 'boolean', 'sortable' => true, 'searchable' => false, @@ -108,8 +95,7 @@ class AttributeDataGrid extends DataGrid $this->addColumn([ 'index' => 'value_per_locale', - 'alias' => 'attributeValuePerLocale', - 'label' => 'Locale Based', + 'label' => trans('admin::app.datagrid.per-locale'), 'type' => 'boolean', 'sortable' => true, 'searchable' => false, @@ -124,8 +110,7 @@ class AttributeDataGrid extends DataGrid $this->addColumn([ 'index' => 'value_per_channel', - 'alias' => 'attributeValuePerChannel', - 'label' => 'Channel Based', + 'label' => trans('admin::app.datagrid.per-channel'), 'type' => 'boolean', 'sortable' => true, 'searchable' => false, @@ -159,6 +144,7 @@ class AttributeDataGrid extends DataGrid $this->addMassAction([ 'type' => 'delete', 'action' => route('admin.catalog.attributes.massdelete'), + 'label' => 'Delete', 'method' => 'DELETE' ]); } diff --git a/packages/Webkul/Admin/src/DataGrids/AttributeFamilyDataGrid.php b/packages/Webkul/Admin/src/DataGrids/AttributeFamilyDataGrid.php index 8900b684d..a5c728b26 100755 --- a/packages/Webkul/Admin/src/DataGrids/AttributeFamilyDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/AttributeFamilyDataGrid.php @@ -6,18 +6,16 @@ use Webkul\Ui\DataGrid\DataGrid; use DB; /** - * Product Data Grid class + * AttributeFamilyDataGrid Class * * @author Prashant Singh @prashant-webkul * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) */ class AttributeFamilyDataGrid extends DataGrid { - public $allColumns = []; + protected $itemsPerPage = 5; - public function __construct() { - $this->itemsPerPage = 10; - } + protected $index = 'id'; //the column that needs to be treated as index column public function prepareQueryBuilder() { @@ -26,16 +24,11 @@ class AttributeFamilyDataGrid extends DataGrid $this->setQueryBuilder($queryBuilder); } - public function setIndex() { - $this->index = 'id'; //the column that needs to be treated as index column - } - public function addColumns() { $this->addColumn([ 'index' => 'id', - 'alias' => 'attributeFamilyId', - 'label' => 'ID', + 'label' => trans('admin::app.datagrid.id'), 'type' => 'number', 'searchable' => false, 'sortable' => true, @@ -44,8 +37,7 @@ class AttributeFamilyDataGrid extends DataGrid $this->addColumn([ 'index' => 'code', - 'alias' => 'attributeFamilyCode', - 'label' => 'Code', + 'label' => trans('admin::app.datagrid.code'), 'type' => 'string', 'searchable' => true, 'sortable' => true, @@ -54,8 +46,7 @@ class AttributeFamilyDataGrid extends DataGrid $this->addColumn([ 'index' => 'name', - 'alias' => 'attributeFamilyName', - 'label' => 'Name', + 'label' => trans('admin::app.datagrid.name'), 'type' => 'string', 'searchable' => true, 'sortable' => true, diff --git a/packages/Webkul/Admin/src/DataGrids/CategoryDataGrid.php b/packages/Webkul/Admin/src/DataGrids/CategoryDataGrid.php index 1b26ceed5..a46398285 100755 --- a/packages/Webkul/Admin/src/DataGrids/CategoryDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/CategoryDataGrid.php @@ -6,36 +6,27 @@ use Webkul\Ui\DataGrid\DataGrid; use DB; /** - * Product Data Grid class + * CategoryDataGrid Class * * @author Prashant Singh @prashant-webkul * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) */ class CategoryDataGrid extends DataGrid { - public $allColumns = []; - - public function __construct() { - $this->itemsPerPage = 10; - } + protected $index = 'category_id'; //the column that needs to be treated as index column public function prepareQueryBuilder() { - $queryBuilder = DB::table('categories as cat')->select('cat.id', 'ct.name', 'cat.position', 'cat.status', 'ct.locale')->leftJoin('category_translations as ct', 'cat.id', '=', 'ct.category_id'); + $queryBuilder = DB::table('categories as cat')->select('cat.id as category_id', 'ct.name as category_name', 'cat.position as category_position', 'cat.status as category_status', 'ct.locale as category_locale')->leftJoin('category_translations as ct', 'cat.id', '=', 'ct.category_id'); $this->setQueryBuilder($queryBuilder); } - public function setIndex() { - $this->index = 'id'; //the column that needs to be treated as index column - } - public function addColumns() { $this->addColumn([ - 'index' => 'cat.id', - 'alias' => 'catId', - 'label' => 'ID', + 'index' => 'category_id', + 'label' => trans('admin::app.datagrid.id'), 'type' => 'number', 'searchable' => false, 'sortable' => true, @@ -43,9 +34,8 @@ class CategoryDataGrid extends DataGrid ]); $this->addColumn([ - 'index' => 'ct.name', - 'alias' => 'catName', - 'label' => 'Name', + 'index' => 'category_name', + 'label' => trans('admin::app.datagrid.name'), 'type' => 'string', 'searchable' => true, 'sortable' => true, @@ -53,9 +43,8 @@ class CategoryDataGrid extends DataGrid ]); $this->addColumn([ - 'index' => 'cat.position', - 'alias' => 'catPosition', - 'label' => 'Position', + 'index' => 'category_position', + 'label' => trans('admin::app.datagrid.position'), 'type' => 'string', 'searchable' => true, 'sortable' => true, @@ -63,9 +52,8 @@ class CategoryDataGrid extends DataGrid ]); $this->addColumn([ - 'index' => 'cat.status', - 'alias' => 'catStatus', - 'label' => 'Status', + 'index' => 'category_status', + 'label' => trans('admin::app.datagrid.status'), 'type' => 'boolean', 'sortable' => true, 'searchable' => true, @@ -79,9 +67,8 @@ class CategoryDataGrid extends DataGrid ]); $this->addColumn([ - 'index' => 'ct.locale', - 'alias' => 'catLocale', - 'label' => 'Locale', + 'index' => 'category_locale', + 'label' => trans('admin::app.datagrid.locale'), 'type' => 'boolean', 'sortable' => true, 'searchable' => false, diff --git a/packages/Webkul/Admin/src/DataGrids/ChannelDataGrid.php b/packages/Webkul/Admin/src/DataGrids/ChannelDataGrid.php index b73b3f8fe..4c25f82da 100755 --- a/packages/Webkul/Admin/src/DataGrids/ChannelDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/ChannelDataGrid.php @@ -6,18 +6,14 @@ use Webkul\Ui\DataGrid\DataGrid; use DB; /** - * Channel Data Grid class + * ChannelDataGrid class * * @author Prashant Singh @prashant-webkul * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) */ class ChannelDataGrid extends DataGrid { - public $allColumns = []; - - public function __construct() { - $this->itemsPerPage = 10; - } + protected $index = 'id'; //the column that needs to be treated as index column public function prepareQueryBuilder() { @@ -26,16 +22,11 @@ class ChannelDataGrid extends DataGrid $this->setQueryBuilder($queryBuilder); } - public function setIndex() { - $this->index = 'id'; //the column that needs to be treated as index column - } - public function addColumns() { $this->addColumn([ 'index' => 'id', - 'alias' => 'channelId', - 'label' => 'ID', + 'label' => trans('admin::app.datagrid.id'), 'type' => 'number', 'searchable' => false, 'sortable' => true, @@ -44,8 +35,7 @@ class ChannelDataGrid extends DataGrid $this->addColumn([ 'index' => 'code', - 'alias' => 'channelCode', - 'label' => 'Code', + 'label' => trans('admin::app.datagrid.code'), 'type' => 'string', 'searchable' => true, 'sortable' => true, @@ -54,8 +44,7 @@ class ChannelDataGrid extends DataGrid $this->addColumn([ 'index' => 'name', - 'alias' => 'channelName', - 'label' => 'Name', + 'label' => trans('admin::app.datagrid.name'), 'type' => 'string', 'searchable' => true, 'sortable' => true, @@ -64,8 +53,7 @@ class ChannelDataGrid extends DataGrid $this->addColumn([ 'index' => 'hostname', - 'alias' => 'channelHostname', - 'label' => 'Hostname', + 'label' => trans('admin::app.datagrid.hostname'), 'type' => 'string', 'sortable' => true, 'searchable' => true, diff --git a/packages/Webkul/Admin/src/DataGrids/CurrencyDataGrid.php b/packages/Webkul/Admin/src/DataGrids/CurrencyDataGrid.php index 24303783b..02652f0b1 100755 --- a/packages/Webkul/Admin/src/DataGrids/CurrencyDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/CurrencyDataGrid.php @@ -6,18 +6,14 @@ use Webkul\Ui\DataGrid\DataGrid; use DB; /** - * Currency Data Grid class + * CurrencyDataGrid class * * @author Prashant Singh @prashant-webkul * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) */ class CurrencyDataGrid extends DataGrid { - public $allColumns = []; - - public function __construct() { - $this->itemsPerPage = 10; - } + protected $index = 'id'; //the column that needs to be treated as index column public function prepareQueryBuilder() { @@ -26,16 +22,11 @@ class CurrencyDataGrid extends DataGrid $this->setQueryBuilder($queryBuilder); } - public function setIndex() { - $this->index = 'id'; //the column that needs to be treated as index column - } - public function addColumns() { $this->addColumn([ 'index' => 'id', - 'alias' => 'currencyId', - 'label' => 'ID', + 'label' => trans('admin::app.datagrid.id'), 'type' => 'number', 'searchable' => false, 'sortable' => true, @@ -44,8 +35,7 @@ class CurrencyDataGrid extends DataGrid $this->addColumn([ 'index' => 'name', - 'alias' => 'currencyName', - 'label' => 'Name', + 'label' => trans('admin::app.datagrid.name'), 'type' => 'string', 'searchable' => true, 'sortable' => true, @@ -54,8 +44,7 @@ class CurrencyDataGrid extends DataGrid $this->addColumn([ 'index' => 'code', - 'alias' => 'currencyCode', - 'label' => 'Code', + 'label' => trans('admin::app.datagrid.code'), 'type' => 'string', 'searchable' => true, 'sortable' => true, diff --git a/packages/Webkul/Admin/src/DataGrids/CustomerDataGrid.php b/packages/Webkul/Admin/src/DataGrids/CustomerDataGrid.php index 0d2311f76..4b7869173 100755 --- a/packages/Webkul/Admin/src/DataGrids/CustomerDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/CustomerDataGrid.php @@ -6,36 +6,29 @@ use Webkul\Ui\DataGrid\DataGrid; use DB; /** - * Currency Data Grid class + * CustomerDataGrid class * * @author Prashant Singh @prashant-webkul * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) */ class CustomerDataGrid extends DataGrid { - public $allColumns = []; + protected $itemsPerPage = 5; - public function __construct() { - $this->itemsPerPage = 10; - } + protected $index = 'customer_id'; //the column that needs to be treated as index column public function prepareQueryBuilder() { - $queryBuilder = DB::table('customers as cus')->addSelect('cus.id', 'cus.first_name', 'cus.email', 'cg.name')->leftJoin('customer_groups as cg', 'cus.customer_group_id', '=', 'cg.id'); + $queryBuilder = DB::table('customers')->addSelect('customers.id as customer_id', 'customers.email as customer_email', 'customer_groups.name as customer_group_name')->addSelect(DB::raw('CONCAT(customers.first_name, " ", customers.last_name) as customer_full_name'))->leftJoin('customer_groups', 'customers.customer_group_id', '=', 'customer_groups.id'); $this->setQueryBuilder($queryBuilder); } - public function setIndex() { - $this->index = 'id'; //the column that needs to be treated as index column - } - public function addColumns() { $this->addColumn([ - 'index' => 'cus.id', - 'alias' => 'customerId', - 'label' => 'ID', + 'index' => 'customer_id', + 'label' => trans('admin::app.datagrid.id'), 'type' => 'number', 'searchable' => false, 'sortable' => true, @@ -43,10 +36,8 @@ class CustomerDataGrid extends DataGrid ]); $this->addColumn([ - // 'column' => 'CONCAT(cus.first_name, " ", cus.last_name)', - 'index' => 'cus.first_name', - 'alias' => 'customerFullName', - 'label' => 'Name', + 'index' => 'customer_full_name', + 'label' => trans('admin::app.datagrid.name'), 'type' => 'string', 'searchable' => true, 'sortable' => true, @@ -54,9 +45,8 @@ class CustomerDataGrid extends DataGrid ]); $this->addColumn([ - 'index' => 'cus.email', - 'alias' => 'customerEmail', - 'label' => 'Email', + 'index' => 'customer_email', + 'label' => trans('admin::app.datagrid.email'), 'type' => 'string', 'searchable' => true, 'sortable' => true, @@ -64,9 +54,8 @@ class CustomerDataGrid extends DataGrid ]); $this->addColumn([ - 'index' => 'cg.name', - 'alias' => 'customerGroupName', - 'label' => 'Group', + 'index' => 'customer_group_name', + 'label' => trans('admin::app.datagrid.group'), 'type' => 'string', 'searchable' => false, 'sortable' => true, diff --git a/packages/Webkul/Admin/src/DataGrids/CustomerGroupDataGrid.php b/packages/Webkul/Admin/src/DataGrids/CustomerGroupDataGrid.php index f1e4b7621..746333d90 100755 --- a/packages/Webkul/Admin/src/DataGrids/CustomerGroupDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/CustomerGroupDataGrid.php @@ -6,18 +6,14 @@ use Webkul\Ui\DataGrid\DataGrid; use DB; /** - * Currency Data Grid class + * CustomerDataGrid class * * @author Prashant Singh @prashant-webkul * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) */ class CustomerGroupDataGrid extends DataGrid { - public $allColumns = []; - - public function __construct() { - $this->itemsPerPage = 10; - } + protected $index = 'id'; //the column that needs to be treated as index column public function prepareQueryBuilder() { @@ -26,15 +22,10 @@ class CustomerGroupDataGrid extends DataGrid $this->setQueryBuilder($queryBuilder); } - public function setIndex() { - $this->index = 'id'; - } - public function addColumns() { $this->addColumn([ 'index' => 'id', - 'alias' => 'groupId', 'label' => 'ID', 'type' => 'number', 'searchable' => false, @@ -43,9 +34,7 @@ class CustomerGroupDataGrid extends DataGrid ]); $this->addColumn([ - // 'column' => 'CONCAT(cus.first_name, " ", cus.last_name)', 'index' => 'name', - 'alias' => 'groupName', 'label' => 'Name', 'type' => 'string', 'searchable' => true, diff --git a/packages/Webkul/Admin/src/DataGrids/CustomerReviewDataGrid.php b/packages/Webkul/Admin/src/DataGrids/CustomerReviewDataGrid.php index 0428ac953..ad4a43e04 100755 --- a/packages/Webkul/Admin/src/DataGrids/CustomerReviewDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/CustomerReviewDataGrid.php @@ -6,36 +6,27 @@ use Webkul\Ui\DataGrid\DataGrid; use DB; /** - * Currency Data Grid class + * CustomerReviewDataGrid Class * * @author Prashant Singh @prashant-webkul * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) */ class CustomerReviewDataGrid extends DataGrid { - public $allColumns = []; - - public function __construct() { - $this->itemsPerPage = 10; - } + protected $index = 'product_review_id'; //the column that needs to be treated as index column public function prepareQueryBuilder() { - $queryBuilder = DB::table('product_reviews as pr')->addSelect('pr.id', 'pr.title', 'pr.comment', 'pg.name', 'pr.status')->leftjoin('products_grid as pg', 'pr.product_id', '=', 'pg.id'); + $queryBuilder = DB::table('product_reviews as pr')->addSelect('pr.id as product_review_id', 'pr.title as product_review_title', 'pr.comment as product_review_comment', 'pg.name as product_review_name', 'pr.status as product_review_status')->leftjoin('products_grid as pg', 'pr.product_id', '=', 'pg.id'); $this->setQueryBuilder($queryBuilder); } - public function setIndex() { - $this->index = 'id'; - } - public function addColumns() { $this->addColumn([ - 'index' => 'pr.id', - 'alias' => 'reviewId', - 'label' => 'ID', + 'index' => 'product_review_id', + 'label' => trans('admin::app.datagrid.id'), 'type' => 'number', 'searchable' => false, 'sortable' => true, @@ -43,9 +34,8 @@ class CustomerReviewDataGrid extends DataGrid ]); $this->addColumn([ - 'index' => 'pr.title', - 'alias' => 'reviewTitle', - 'label' => 'Title', + 'index' => 'product_review_title', + 'label' => trans('admin::app.datagrid.title'), 'type' => 'string', 'searchable' => true, 'sortable' => true, @@ -53,9 +43,8 @@ class CustomerReviewDataGrid extends DataGrid ]); $this->addColumn([ - 'index' => 'pr.comment', - 'alias' => 'reviewComment', - 'label' => 'Comment', + 'index' => 'product_review_comment', + 'label' => trans('admin::app.datagrid.comment'), 'type' => 'string', 'searchable' => true, 'sortable' => true, @@ -63,9 +52,8 @@ class CustomerReviewDataGrid extends DataGrid ]); $this->addColumn([ - 'index' => 'pg.name', - 'alias' => 'productName', - 'label' => 'Product', + 'index' => 'product_review_name', + 'label' => trans('admin::app.datagrid.product-name'), 'type' => 'string', 'searchable' => true, 'sortable' => true, @@ -73,9 +61,8 @@ class CustomerReviewDataGrid extends DataGrid ]); $this->addColumn([ - 'index' => 'pr.status', - 'alias' => 'reviewStatus', - 'label' => 'Status', + 'index' => 'product_review_status', + 'label' => trans('admin::app.datagrid.status'), 'type' => 'boolean', 'searchable' => true, 'sortable' => true, @@ -107,12 +94,14 @@ class CustomerReviewDataGrid extends DataGrid public function prepareMassActions() { $this->addMassAction([ 'type' => 'delete', + 'label' => 'Delete', 'action' => route('admin.customer.review.massdelete'), 'method' => 'DELETE' ]); $this->addMassAction([ 'type' => 'update', + 'label' => 'Update Status', 'action' => route('admin.customer.review.massupdate'), 'method' => 'PUT', 'options' => [ diff --git a/packages/Webkul/Admin/src/DataGrids/ExchangeRatesDataGrid.php b/packages/Webkul/Admin/src/DataGrids/ExchangeRatesDataGrid.php index 4d76ed7a3..7d6bd7234 100755 --- a/packages/Webkul/Admin/src/DataGrids/ExchangeRatesDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/ExchangeRatesDataGrid.php @@ -6,36 +6,27 @@ use Webkul\Ui\DataGrid\DataGrid; use DB; /** - * Product Data Grid class + * ExchangeRateDataGrid Class * * @author Prashant Singh @prashant-webkul * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) */ class ExchangeRatesDataGrid extends DataGrid { - public $allColumns = []; - - public function __construct() { - $this->itemsPerPage = 10; - } + protected $index = 'currency_exch_id'; public function prepareQueryBuilder() { - $queryBuilder = DB::table('currency_exchange_rates as cer')->addSelect('cer.id', 'curr.name', 'cer.rate')->leftJoin('currencies as curr', 'cer.target_currency', '=', 'curr.id'); + $queryBuilder = DB::table('currency_exchange_rates as cer')->addSelect('cer.id as currency_exch_id', 'curr.name as currency_exch_name', 'cer.rate as currency_exch_rate')->leftJoin('currencies as curr', 'cer.target_currency', '=', 'curr.id'); $this->setQueryBuilder($queryBuilder); } - public function setIndex() { - $this->index = 'id'; - } - public function addColumns() { $this->addColumn([ - 'index' => 'cer.id', - 'alias' => 'exchId', - 'label' => 'ID', + 'index' => 'currency_exch_id', + 'label' => trans('admin::app.datagrid.id'), 'type' => 'number', 'searchable' => false, 'sortable' => true, @@ -43,9 +34,8 @@ class ExchangeRatesDataGrid extends DataGrid ]); $this->addColumn([ - 'index' => 'curr.name', - 'alias' => 'exchName', - 'label' => 'Currency Name', + 'index' => 'currency_exch_name', + 'label' => trans('admin::app.datagrid.currency-name'), 'type' => 'string', 'searchable' => true, 'sortable' => true, @@ -53,9 +43,8 @@ class ExchangeRatesDataGrid extends DataGrid ]); $this->addColumn([ - 'index' => 'cer.rate', - 'alias' => 'exchRate', - 'label' => 'Exchange Rate', + 'index' => 'currency_exch_rate', + 'label' => trans('admin::app.datagrid.exch-rate'), 'type' => 'string', 'searchable' => true, 'sortable' => true, diff --git a/packages/Webkul/Admin/src/DataGrids/InventorySourcesDataGrid.php b/packages/Webkul/Admin/src/DataGrids/InventorySourcesDataGrid.php index 8cac66ece..0d899faa4 100755 --- a/packages/Webkul/Admin/src/DataGrids/InventorySourcesDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/InventorySourcesDataGrid.php @@ -6,18 +6,14 @@ use Webkul\Ui\DataGrid\DataGrid; use DB; /** - * Product Data Grid class + * InventorySourcesDataGrid Class * * @author Prashant Singh @prashant-webkul * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) */ class InventorySourcesDataGrid extends DataGrid { - public $allColumns = []; - - public function __construct() { - $this->itemsPerPage = 10; - } + protected $index = 'id'; public function prepareQueryBuilder() { @@ -26,16 +22,11 @@ class InventorySourcesDataGrid extends DataGrid $this->setQueryBuilder($queryBuilder); } - public function setIndex() { - $this->index = 'id'; - } - public function addColumns() { $this->addColumn([ 'index' => 'id', - 'alias' => 'invId', - 'label' => 'ID', + 'label' => trans('admin::app.datagrid.id'), 'type' => 'number', 'searchable' => false, 'sortable' => true, @@ -44,8 +35,7 @@ class InventorySourcesDataGrid extends DataGrid $this->addColumn([ 'index' => 'code', - 'alias' => 'invCode', - 'label' => 'Code', + 'label' => trans('admin::app.datagrid.code'), 'type' => 'string', 'searchable' => true, 'sortable' => true, @@ -54,8 +44,7 @@ class InventorySourcesDataGrid extends DataGrid $this->addColumn([ 'index' => 'name', - 'alias' => 'invName', - 'label' => 'Name', + 'label' => trans('admin::app.datagrid.name'), 'type' => 'string', 'searchable' => true, 'sortable' => true, @@ -64,8 +53,7 @@ class InventorySourcesDataGrid extends DataGrid $this->addColumn([ 'index' => 'priority', - 'alias' => 'invPriority', - 'label' => 'Priority', + 'label' => trans('admin::app.datagrid.priority'), 'type' => 'string', 'searchable' => true, 'sortable' => true, @@ -74,8 +62,7 @@ class InventorySourcesDataGrid extends DataGrid $this->addColumn([ 'index' => 'status', - 'alias' => 'invStatus', - 'label' => 'Status', + 'label' => trans('admin::app.datagrid.status'), 'type' => 'boolean', 'searchable' => true, 'sortable' => true, diff --git a/packages/Webkul/Admin/src/DataGrids/LocalesDataGrid.php b/packages/Webkul/Admin/src/DataGrids/LocalesDataGrid.php index a185b5e73..09900efbe 100755 --- a/packages/Webkul/Admin/src/DataGrids/LocalesDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/LocalesDataGrid.php @@ -6,18 +6,14 @@ use Webkul\Ui\DataGrid\DataGrid; use DB; /** - * Product Data Grid class + * LocalesDataGrid Class * * @author Prashant Singh @prashant-webkul * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) */ class LocalesDataGrid extends DataGrid { - public $allColumns = []; - - public function __construct() { - $this->itemsPerPage = 10; - } + protected $index = 'id'; public function prepareQueryBuilder() { @@ -26,16 +22,11 @@ class LocalesDataGrid extends DataGrid $this->setQueryBuilder($queryBuilder); } - public function setIndex() { - $this->index = 'id'; - } - public function addColumns() { $this->addColumn([ 'index' => 'id', - 'alias' => 'localeId', - 'label' => 'ID', + 'label' => trans('admin::app.datagrid.id'), 'type' => 'number', 'searchable' => false, 'sortable' => true, @@ -44,8 +35,7 @@ class LocalesDataGrid extends DataGrid $this->addColumn([ 'index' => 'code', - 'alias' => 'localeCode', - 'label' => 'Code', + 'label' => trans('admin::app.datagrid.code'), 'type' => 'string', 'searchable' => true, 'sortable' => true, @@ -54,8 +44,7 @@ class LocalesDataGrid extends DataGrid $this->addColumn([ 'index' => 'name', - 'alias' => 'localeName', - 'label' => 'Name', + 'label' => trans('admin::app.datagrid.name'), 'type' => 'string', 'searchable' => true, 'sortable' => true, diff --git a/packages/Webkul/Admin/src/DataGrids/NewsLetterDataGrid.php b/packages/Webkul/Admin/src/DataGrids/NewsLetterDataGrid.php index 21c0dc18d..d733fa510 100755 --- a/packages/Webkul/Admin/src/DataGrids/NewsLetterDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/NewsLetterDataGrid.php @@ -6,18 +6,14 @@ use Webkul\Ui\DataGrid\DataGrid; use DB; /** - * News Letter Grid class + * NewsLetterDataGrid Class * * @author Prashant Singh @prashant-webkul * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) */ class NewsLetterDataGrid extends DataGrid { - public $allColumns = []; - - public function __construct() { - $this->itemsPerPage = 10; - } + protected $index = 'id'; public function prepareQueryBuilder() { @@ -26,16 +22,11 @@ class NewsLetterDataGrid extends DataGrid $this->setQueryBuilder($queryBuilder); } - public function setIndex() { - $this->index = 'id'; - } - public function addColumns() { $this->addColumn([ 'index' => 'id', - 'alias' => 'subsId', - 'label' => 'ID', + 'label' => trans('admin::app.datagrid.id'), 'type' => 'number', 'searchable' => false, 'sortable' => true, @@ -44,8 +35,7 @@ class NewsLetterDataGrid extends DataGrid $this->addColumn([ 'index' => 'is_subscribed', - 'alias' => 'subsCode', - 'label' => 'Subscribed', + 'label' => trans('admin::app.datagrid.subscribed'), 'type' => 'string', 'searchable' => true, 'sortable' => true, @@ -60,8 +50,7 @@ class NewsLetterDataGrid extends DataGrid $this->addColumn([ 'index' => 'email', - 'alias' => 'subsEmail', - 'label' => 'Email', + 'label' => trans('admin::app.datagrid.email'), 'type' => 'string', 'searchable' => true, 'sortable' => true, diff --git a/packages/Webkul/Admin/src/DataGrids/OrderDataGrid.php b/packages/Webkul/Admin/src/DataGrids/OrderDataGrid.php index 3e488cfbe..205fac3ac 100755 --- a/packages/Webkul/Admin/src/DataGrids/OrderDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/OrderDataGrid.php @@ -6,36 +6,27 @@ use Webkul\Ui\DataGrid\DataGrid; use DB; /** - * Product Data Grid class + * OrderDataGrid Class * * @author Prashant Singh @prashant-webkul * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) */ class OrderDataGrid extends DataGrid { - public $allColumns = []; - - public function __construct() { - $this->itemsPerPage = 10; - } + protected $index = 'id'; public function prepareQueryBuilder() { - $queryBuilder = DB::table('orders')->select('id', 'base_grand_total', 'grand_total', 'created_at', 'channel_name', 'status')->addSelect(DB::raw('CONCAT(customer_first_name, " ", customer_last_name) as fullname')); + $queryBuilder = DB::table('orders')->select('id', 'base_grand_total', 'grand_total', 'created_at', 'channel_name', 'status')->addSelect(DB::raw('CONCAT(customer_first_name, " ", customer_last_name) as full_name')); $this->setQueryBuilder($queryBuilder); } - public function setIndex() { - $this->index = 'id'; //the column that needs to be treated as index column - } - public function addColumns() { $this->addColumn([ 'index' => 'id', - 'alias' => 'orderId', - 'label' => 'ID', + 'label' => trans('admin::app.datagrid.id'), 'type' => 'number', 'searchable' => false, 'sortable' => true, @@ -44,8 +35,7 @@ class OrderDataGrid extends DataGrid $this->addColumn([ 'index' => 'base_grand_total', - 'alias' => 'baseGrandTotal', - 'label' => 'Base Total', + 'label' => trans('admin::app.datagrid.base-total'), 'type' => 'string', 'searchable' => true, 'sortable' => true, @@ -57,8 +47,7 @@ class OrderDataGrid extends DataGrid $this->addColumn([ 'index' => 'grand_total', - 'alias' => 'grandTotal', - 'label' => 'Grand Total', + 'label' => trans('admin::app.datagrid.grand-total'), 'type' => 'string', 'searchable' => true, 'sortable' => true, @@ -70,8 +59,7 @@ class OrderDataGrid extends DataGrid $this->addColumn([ 'index' => 'created_at', - 'alias' => 'orderDate', - 'label' => 'Order Date', + 'label' => trans('admin::app.datagrid.order-date'), 'type' => 'string', 'sortable' => true, 'searchable' => true, @@ -80,8 +68,7 @@ class OrderDataGrid extends DataGrid $this->addColumn([ 'index' => 'channel_name', - 'alias' => 'channelName', - 'label' => 'Channel Name', + 'label' => trans('admin::app.datagrid.channel-name'), 'type' => 'string', 'sortable' => true, 'searchable' => false, @@ -90,8 +77,7 @@ class OrderDataGrid extends DataGrid $this->addColumn([ 'index' => 'status', - 'alias' => 'status', - 'label' => 'Status', + 'label' => trans('admin::app.datagrid.status'), 'type' => 'string', 'sortable' => true, 'searchable' => false, @@ -116,9 +102,8 @@ class OrderDataGrid extends DataGrid ]); $this->addColumn([ - 'index' => 'fullname', - 'alias' => 'fullName', - 'label' => 'Billed To', + 'index' => 'full_name', + 'label' => trans('admin::app.datagrid.billed-to'), 'type' => 'string', 'searchable' => false, 'sortable' => true, diff --git a/packages/Webkul/Admin/src/DataGrids/OrderInvoicesDataGrid.php b/packages/Webkul/Admin/src/DataGrids/OrderInvoicesDataGrid.php index 8470ae8cb..d3fb5a42c 100755 --- a/packages/Webkul/Admin/src/DataGrids/OrderInvoicesDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/OrderInvoicesDataGrid.php @@ -6,18 +6,14 @@ use Webkul\Ui\DataGrid\DataGrid; use DB; /** - * Product Data Grid class + * OrderInvoicesDataGrid Class * * @author Prashant Singh @prashant-webkul * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) */ class OrderInvoicesDataGrid extends DataGrid { - public $allColumns = []; - - public function __construct() { - $this->itemsPerPage = 10; - } + protected $index = 'id'; public function prepareQueryBuilder() { @@ -26,16 +22,11 @@ class OrderInvoicesDataGrid extends DataGrid $this->setQueryBuilder($queryBuilder); } - public function setIndex() { - $this->index = 'id'; //the column that needs to be treated as index column - } - public function addColumns() { $this->addColumn([ 'index' => 'id', - 'alias' => 'invid', - 'label' => 'ID', + 'label' => trans('admin::app.datagrid.id'), 'type' => 'number', 'searchable' => false, 'sortable' => true, @@ -44,8 +35,7 @@ class OrderInvoicesDataGrid extends DataGrid $this->addColumn([ 'index' => 'order_id', - 'alias' => 'orderId', - 'label' => 'Order ID', + 'label' => trans('admin::app.datagrid.order-id'), 'type' => 'number', 'searchable' => false, 'sortable' => true, @@ -54,8 +44,7 @@ class OrderInvoicesDataGrid extends DataGrid $this->addColumn([ 'index' => 'grand_total', - 'alias' => 'invgrandtotal', - 'label' => 'Grand Total', + 'label' => trans('admin::app.datagrid.grand-total'), 'type' => 'string', 'searchable' => true, 'sortable' => true, @@ -64,8 +53,7 @@ class OrderInvoicesDataGrid extends DataGrid $this->addColumn([ 'index' => 'created_at', - 'alias' => 'invcreatedat', - 'label' => 'Invoice Date', + 'label' => trans('admin::app.datagrid.invoice-date'), 'type' => 'datetime', 'searchable' => true, 'sortable' => true, diff --git a/packages/Webkul/Admin/src/DataGrids/OrderShipmentsDataGrid.php b/packages/Webkul/Admin/src/DataGrids/OrderShipmentsDataGrid.php index 55d0b4fbc..b1a1b8b46 100755 --- a/packages/Webkul/Admin/src/DataGrids/OrderShipmentsDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/OrderShipmentsDataGrid.php @@ -6,36 +6,27 @@ use Webkul\Ui\DataGrid\DataGrid; use DB; /** - * Product Data Grid class + * OrderShipmentsDataGrid Class * * @author Prashant Singh @prashant-webkul * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) */ class OrderShipmentsDataGrid extends DataGrid { - public $allColumns = []; - - public function __construct() { - $this->itemsPerPage = 10; - } + protected $index = 'shipment_id'; public function prepareQueryBuilder() { - $queryBuilder = DB::table('shipments as ship')->select('ship.id', 'ship.order_id', 'ship.total_qty', 'is.name', 'ors.created_at as orderdate', 'ship.created_at')->addSelect(DB::raw('CONCAT(ors.customer_first_name, " ", ors.customer_last_name) as custname'))->leftJoin('orders as ors', 'ship.order_id', '=', 'ors.id')->leftJoin('inventory_sources as is', 'ship.inventory_source_id', '=', 'is.id'); + $queryBuilder = DB::table('shipments as ship')->select('ship.id as shipment_id', 'ship.order_id as shipment_order_id', 'ship.total_qty as shipment_total_qty', 'is.name as inventory_source_name', 'ors.created_at as orderdate', 'ship.created_at as shipment_created_at')->addSelect(DB::raw('CONCAT(ors.customer_first_name, " ", ors.customer_last_name) as custname'))->leftJoin('orders as ors', 'ship.order_id', '=', 'ors.id')->leftJoin('inventory_sources as is', 'ship.inventory_source_id', '=', 'is.id'); $this->setQueryBuilder($queryBuilder); } - public function setIndex() { - $this->index = 'id'; //the column that needs to be treated as index column - } - public function addColumns() { $this->addColumn([ - 'index' => 'ship.id', - 'alias' => 'shipId', - 'label' => 'ID', + 'index' => 'shipment_id', + 'label' => trans('admin::app.datagrid.id'), 'type' => 'number', 'searchable' => false, 'sortable' => true, @@ -43,9 +34,8 @@ class OrderShipmentsDataGrid extends DataGrid ]); $this->addColumn([ - 'index' => 'ship.order_id', - 'alias' => 'orderId', - 'label' => 'Order ID', + 'index' => 'shipment_order_id', + 'label' => trans('admin::app.datagrid.order-id'), 'type' => 'number', 'searchable' => false, 'sortable' => true, @@ -53,9 +43,8 @@ class OrderShipmentsDataGrid extends DataGrid ]); $this->addColumn([ - 'index' => 'ship.total_qty', - 'alias' => 'shipTotalQty', - 'label' => 'Total Qty', + 'index' => 'shipment_total_qty', + 'label' => trans('admin::app.datagrid.total-qty'), 'type' => 'number', 'searchable' => true, 'sortable' => true, @@ -63,9 +52,8 @@ class OrderShipmentsDataGrid extends DataGrid ]); $this->addColumn([ - 'index' => 'is.name', - 'alias' => 'shipInventoryName', - 'label' => 'Inventory Source', + 'index' => 'inventory_source_name', + 'label' => trans('admin::app.datagrid.inventory-source'), 'type' => 'string', 'searchable' => true, 'sortable' => true, @@ -74,8 +62,7 @@ class OrderShipmentsDataGrid extends DataGrid $this->addColumn([ 'index' => 'orderdate', - 'alias' => 'shipOrderDate', - 'label' => 'Order Date', + 'label' => trans('admin::app.datagrid.order-date'), 'type' => 'datetime', 'sortable' => true, 'searchable' => true, @@ -83,9 +70,8 @@ class OrderShipmentsDataGrid extends DataGrid ]); $this->addColumn([ - 'index' => 'ship.created_at', - 'alias' => 'shipDate', - 'label' => 'Shipment Date', + 'index' => 'shipment_created_at', + 'label' => trans('admin::app.datagrid.shipment-date'), 'type' => 'datetime', 'sortable' => true, 'searchable' => false, @@ -94,8 +80,7 @@ class OrderShipmentsDataGrid extends DataGrid $this->addColumn([ 'index' => 'custname', - 'alias' => 'shipTO', - 'label' => 'Shipping To', + 'label' => trans('admin::app.datagrid.shipment-to'), 'type' => 'string', 'sortable' => true, 'searchable' => false, diff --git a/packages/Webkul/Admin/src/DataGrids/ProductDataGrid.php b/packages/Webkul/Admin/src/DataGrids/ProductDataGrid.php index a9e7028e5..bf939e6a0 100644 --- a/packages/Webkul/Admin/src/DataGrids/ProductDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/ProductDataGrid.php @@ -6,40 +6,27 @@ use Webkul\Ui\DataGrid\DataGrid; use DB; /** - * Product Data Grid class + * ProductDataGrid Class * * @author Prashant Singh @prashant-webkul * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) */ class ProductDataGrid extends DataGrid { - public $allColumns = []; - - public function __construct() { - $this->itemsPerPage = 10; - } + protected $index = 'product_id'; public function prepareQueryBuilder() { - $queryBuilder = DB::table('products_grid')->addSelect('products_grid.product_id', 'products_grid.sku', 'products_grid.name', 'products.type', 'products_grid.status', 'products_grid.price', 'products_grid.quantity')->leftJoin('products', 'products_grid.product_id', '=', 'products.id'); + $queryBuilder = DB::table('products_grid')->addSelect('products_grid.product_id as product_id', 'products_grid.sku as product_sku', 'products_grid.name as product_name', 'products.type as product_type', 'products_grid.status as product_status', 'products_grid.price as product_price', 'products_grid.quantity as product_quantity')->leftJoin('products', 'products_grid.product_id', '=', 'products.id'); $this->setQueryBuilder($queryBuilder); } - public function setIndex() { - $this->index = 'product_id'; //the column that needs to be treated as index column - } - - // public function setGridName() { - // $this->gridName = 'products_grid'; // should be the table name for getting proper index - // } - public function addColumns() { $this->addColumn([ - 'index' => 'products_grid.product_id', - 'alias' => 'productid', - 'label' => 'ID', + 'index' => 'product_id', + 'label' => trans('admin::app.datagrid.id'), 'type' => 'number', 'searchable' => false, 'sortable' => true, @@ -47,9 +34,8 @@ class ProductDataGrid extends DataGrid ]); $this->addColumn([ - 'index' => 'products_grid.sku', - 'alias' => 'productsku', - 'label' => 'SKU', + 'index' => 'product_sku', + 'label' => trans('admin::app.datagrid.sku'), 'type' => 'string', 'searchable' => true, 'sortable' => true, @@ -57,9 +43,8 @@ class ProductDataGrid extends DataGrid ]); $this->addColumn([ - 'index' => 'products_grid.name', - 'alias' => 'productname', - 'label' => 'Name', + 'index' => 'product_name', + 'label' => trans('admin::app.datagrid.name'), 'type' => 'string', 'searchable' => true, 'sortable' => true, @@ -67,9 +52,8 @@ class ProductDataGrid extends DataGrid ]); $this->addColumn([ - 'index' => 'products.type', - 'alias' => 'producttype', - 'label' => 'Type', + 'index' => 'product_type', + 'label' => trans('admin::app.datagrid.type'), 'type' => 'string', 'sortable' => true, 'searchable' => true, @@ -77,9 +61,8 @@ class ProductDataGrid extends DataGrid ]); $this->addColumn([ - 'index' => 'products_grid.status', - 'alias' => 'productstatus', - 'label' => 'Status', + 'index' => 'product_status', + 'label' => trans('admin::app.datagrid.status'), 'type' => 'boolean', 'sortable' => true, 'searchable' => false, @@ -93,9 +76,8 @@ class ProductDataGrid extends DataGrid ]); $this->addColumn([ - 'index' => 'products_grid.price', - 'alias' => 'productprice', - 'label' => 'Price', + 'index' => 'product_price', + 'label' => trans('admin::app.datagrid.price'), 'type' => 'number', 'sortable' => true, 'searchable' => false, @@ -106,9 +88,8 @@ class ProductDataGrid extends DataGrid ]); $this->addColumn([ - 'index' => 'products_grid.quantity', - 'alias' => 'productqty', - 'label' => 'Quantity', + 'index' => 'product_quantity', + 'label' => trans('admin::app.datagrid.qty'), 'type' => 'number', 'sortable' => true, 'searchable' => false, @@ -134,12 +115,14 @@ class ProductDataGrid extends DataGrid public function prepareMassActions() { $this->addMassAction([ 'type' => 'delete', + 'label' => 'Delete', 'action' => route('admin.catalog.products.massdelete'), 'method' => 'DELETE' ]); $this->addMassAction([ 'type' => 'update', + 'label' => 'Update Status', 'action' => route('admin.catalog.products.massupdate'), 'method' => 'PUT', 'options' => [ diff --git a/packages/Webkul/Admin/src/DataGrids/RolesDataGrid.php b/packages/Webkul/Admin/src/DataGrids/RolesDataGrid.php index 8d672fa6c..88814b9f1 100755 --- a/packages/Webkul/Admin/src/DataGrids/RolesDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/RolesDataGrid.php @@ -6,18 +6,14 @@ use Webkul\Ui\DataGrid\DataGrid; use DB; /** - * News Letter Grid class + * RolesDataGrid Class * * @author Prashant Singh @prashant-webkul * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) */ class RolesDataGrid extends DataGrid { - public $allColumns = []; - - public function __construct() { - $this->itemsPerPage = 10; - } + protected $index = 'id'; public function prepareQueryBuilder() { @@ -26,16 +22,11 @@ class RolesDataGrid extends DataGrid $this->setQueryBuilder($queryBuilder); } - public function setIndex() { - $this->index = 'id'; - } - public function addColumns() { $this->addColumn([ 'index' => 'id', - 'alias' => 'roleId', - 'label' => 'ID', + 'label' => trans('admin::app.datagrid.id'), 'type' => 'number', 'searchable' => false, 'sortable' => true, @@ -44,8 +35,7 @@ class RolesDataGrid extends DataGrid $this->addColumn([ 'index' => 'name', - 'alias' => 'roleName', - 'label' => 'Name', + 'label' => trans('admin::app.datagrid.name'), 'type' => 'string', 'searchable' => true, 'sortable' => true, @@ -54,8 +44,7 @@ class RolesDataGrid extends DataGrid $this->addColumn([ 'index' => 'permission_type', - 'alias' => 'roleType', - 'label' => 'Permission Type', + 'label' => trans('admin::app.datagrid.permission-type'), 'type' => 'string', 'searchable' => true, 'sortable' => true, diff --git a/packages/Webkul/Admin/src/DataGrids/SliderDataGrid.php b/packages/Webkul/Admin/src/DataGrids/SliderDataGrid.php index 0b5b7b93c..74aef6d05 100755 --- a/packages/Webkul/Admin/src/DataGrids/SliderDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/SliderDataGrid.php @@ -6,36 +6,27 @@ use Webkul\Ui\DataGrid\DataGrid; use DB; /** - * News Letter Grid class + * SliderDataGrid Class * * @author Prashant Singh @prashant-webkul * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) */ class SliderDataGrid extends DataGrid { - public $allColumns = []; - - public function __construct() { - $this->itemsPerPage = 10; - } + protected $index = 'slider_id'; public function prepareQueryBuilder() { - $queryBuilder = DB::table('sliders as sl')->addSelect('sl.id', 'sl.title', 'ch.name')->leftJoin('channels as ch', 'sl.channel_id', '=', 'ch.id'); + $queryBuilder = DB::table('sliders as sl')->addSelect('sl.id as slider_id', 'sl.title as slider_title', 'ch.name as channel_name')->leftJoin('channels as ch', 'sl.channel_id', '=', 'ch.id'); $this->setQueryBuilder($queryBuilder); } - public function setIndex() { - $this->index = 'id'; - } - public function addColumns() { $this->addColumn([ - 'index' => 'sl.id', - 'alias' => 'sliderId', - 'label' => 'ID', + 'index' => 'slider_id', + 'label' => trans('admin::app.datagrid.id'), 'type' => 'number', 'searchable' => false, 'sortable' => true, @@ -43,9 +34,8 @@ class SliderDataGrid extends DataGrid ]); $this->addColumn([ - 'index' => 'sl.title', - 'alias' => 'sliderTitle', - 'label' => 'Tile', + 'index' => 'slider_title', + 'label' => trans('admin::app.datagrid.title'), 'type' => 'string', 'searchable' => true, 'sortable' => true, @@ -53,9 +43,8 @@ class SliderDataGrid extends DataGrid ]); $this->addColumn([ - 'index' => 'ch.name', - 'alias' => 'channelName', - 'label' => 'Channel Name', + 'index' => 'channel_name', + 'label' => trans('admin::app.datagrid.channel-name'), 'type' => 'string', 'searchable' => true, 'sortable' => true, diff --git a/packages/Webkul/Admin/src/DataGrids/TaxCategoryDataGrid.php b/packages/Webkul/Admin/src/DataGrids/TaxCategoryDataGrid.php index b3243341c..0098a80e6 100755 --- a/packages/Webkul/Admin/src/DataGrids/TaxCategoryDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/TaxCategoryDataGrid.php @@ -6,18 +6,14 @@ use Webkul\Ui\DataGrid\DataGrid; use DB; /** - * Tax Category Grid class + * TaxCategoryDataGrid Class * * @author Prashant Singh @prashant-webkul * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) */ class TaxCategoryDataGrid extends DataGrid { - public $allColumns = []; - - public function __construct() { - $this->itemsPerPage = 10; - } + protected $index = 'id'; public function prepareQueryBuilder() { @@ -26,16 +22,11 @@ class TaxCategoryDataGrid extends DataGrid $this->setQueryBuilder($queryBuilder); } - public function setIndex() { - $this->index = 'id'; - } - public function addColumns() { $this->addColumn([ 'index' => 'id', - 'alias' => 'taxCatId', - 'label' => 'ID', + 'label' => trans('admin::app.datagrid.id'), 'type' => 'number', 'searchable' => false, 'sortable' => true, @@ -44,8 +35,7 @@ class TaxCategoryDataGrid extends DataGrid $this->addColumn([ 'index' => 'name', - 'alias' => 'taxCatName', - 'label' => 'Name', + 'label' => trans('admin::app.datagrid.name'), 'type' => 'string', 'searchable' => true, 'sortable' => true, @@ -54,8 +44,7 @@ class TaxCategoryDataGrid extends DataGrid $this->addColumn([ 'index' => 'code', - 'alias' => 'taxCatCode', - 'label' => 'Code', + 'label' => trans('admin::app.datagrid.code'), 'type' => 'string', 'searchable' => true, 'sortable' => true, diff --git a/packages/Webkul/Admin/src/DataGrids/TaxRateDataGrid.php b/packages/Webkul/Admin/src/DataGrids/TaxRateDataGrid.php index b6035b400..7beca667c 100755 --- a/packages/Webkul/Admin/src/DataGrids/TaxRateDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/TaxRateDataGrid.php @@ -6,18 +6,14 @@ use Webkul\Ui\DataGrid\DataGrid; use DB; /** - * Tax Rate Grid class + * TaxRateDataGrid Class * * @author Prashant Singh @prashant-webkul * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) */ class TaxRateDataGrid extends DataGrid { - public $allColumns = []; - - public function __construct() { - $this->itemsPerPage = 10; - } + protected $index = 'id'; public function prepareQueryBuilder() { @@ -26,16 +22,11 @@ class TaxRateDataGrid extends DataGrid $this->setQueryBuilder($queryBuilder); } - public function setIndex() { - $this->index = 'id'; - } - public function addColumns() { $this->addColumn([ 'index' => 'id', - 'alias' => 'taxRateId', - 'label' => 'ID', + 'label' => trans('admin::app.datagrid.id'), 'type' => 'number', 'searchable' => false, 'sortable' => true, @@ -44,8 +35,7 @@ class TaxRateDataGrid extends DataGrid $this->addColumn([ 'index' => 'identifier', - 'alias' => 'taxRateName', - 'label' => 'Identifier', + 'label' => trans('admin::app.datagrid.identifier'), 'type' => 'string', 'searchable' => true, 'sortable' => true, @@ -54,8 +44,7 @@ class TaxRateDataGrid extends DataGrid $this->addColumn([ 'index' => 'state', - 'alias' => 'taxRateState', - 'label' => 'State', + 'label' => trans('admin::app.datagrid.state'), 'type' => 'string', 'searchable' => true, 'sortable' => true, @@ -64,8 +53,7 @@ class TaxRateDataGrid extends DataGrid $this->addColumn([ 'index' => 'country', - 'alias' => 'taxRateCountry', - 'label' => 'Country', + 'label' => trans('admin::app.datagrid.country'), 'type' => 'string', 'searchable' => true, 'sortable' => true, @@ -74,8 +62,7 @@ class TaxRateDataGrid extends DataGrid $this->addColumn([ 'index' => 'tax_rate', - 'alias' => 'taxRate', - 'label' => 'Rate', + 'label' => trans('admin::app.datagrid.tax-rate'), 'type' => 'string', 'searchable' => true, 'sortable' => true, diff --git a/packages/Webkul/Admin/src/DataGrids/UserDataGrid.php b/packages/Webkul/Admin/src/DataGrids/UserDataGrid.php index 14b09cd6e..673f5937f 100755 --- a/packages/Webkul/Admin/src/DataGrids/UserDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/UserDataGrid.php @@ -6,36 +6,27 @@ use Webkul\Ui\DataGrid\DataGrid; use DB; /** - * News Letter Grid class + * UserDataGrid Class * * @author Prashant Singh @prashant-webkul * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) */ class UserDataGrid extends DataGrid { - public $allColumns = []; - - public function __construct() { - $this->itemsPerPage = 10; - } + protected $index = 'user_id'; public function prepareQueryBuilder() { - $queryBuilder = DB::table('admins as u')->addSelect('u.id', 'u.name', 'u.status', 'u.email', 'ro.name')->leftJoin('roles as ro', 'u.role_id', '=', 'ro.id'); + $queryBuilder = DB::table('admins as u')->addSelect('u.id as user_id', 'u.name as user_name', 'u.status as user_status', 'u.email as user_email', 'ro.name as role_name')->leftJoin('roles as ro', 'u.role_id', '=', 'ro.id'); $this->setQueryBuilder($queryBuilder); } - public function setIndex() { - $this->index = 'id'; - } - public function addColumns() { $this->addColumn([ - 'index' => 'u.id', - 'alias' => 'adminId', - 'label' => 'ID', + 'index' => 'user_id', + 'label' => trans('admin::app.datagrid.id'), 'type' => 'number', 'searchable' => false, 'sortable' => true, @@ -43,9 +34,8 @@ class UserDataGrid extends DataGrid ]); $this->addColumn([ - 'index' => 'u.name', - 'alias' => 'adminName', - 'label' => 'Name', + 'index' => 'user_name', + 'label' => trans('admin::app.datagrid.name'), 'type' => 'string', 'searchable' => true, 'sortable' => true, @@ -53,9 +43,8 @@ class UserDataGrid extends DataGrid ]); $this->addColumn([ - 'index' => 'u.status', - 'alias' => 'adminStatus', - 'label' => 'Status', + 'index' => 'user_status', + 'label' => trans('admin::app.datagrid.status'), 'type' => 'boolean', 'searchable' => true, 'sortable' => true, @@ -70,9 +59,8 @@ class UserDataGrid extends DataGrid ]); $this->addColumn([ - 'index' => 'u.email', - 'alias' => 'adminEmail', - 'label' => 'Email', + 'index' => 'user_email', + 'label' => trans('admin::app.datagrid.email'), 'type' => 'string', 'searchable' => true, 'sortable' => true, diff --git a/packages/Webkul/Admin/src/Http/Controllers/Customer/CustomerController.php b/packages/Webkul/Admin/src/Http/Controllers/Customer/CustomerController.php index 6da778870..59bd01ec5 100755 --- a/packages/Webkul/Admin/src/Http/Controllers/Customer/CustomerController.php +++ b/packages/Webkul/Admin/src/Http/Controllers/Customer/CustomerController.php @@ -103,7 +103,6 @@ class CustomerController extends Controller 'first_name' => 'string|required', 'last_name' => 'string|required', 'gender' => 'required', - 'phone' => 'nullable|numeric|unique:customers,phone', 'email' => 'required|unique:customers,email', 'date_of_birth' => 'date|before:today' ]); @@ -112,7 +111,9 @@ class CustomerController extends Controller $password = bcrypt(rand(100000,10000000)); - $data['password']=$password; + $data['password'] = $password; + + $data['is_verified'] = 1; $this->customer->create($data); diff --git a/packages/Webkul/Admin/src/Resources/lang/en/app.php b/packages/Webkul/Admin/src/Resources/lang/en/app.php index b15556abb..4ec39b742 100755 --- a/packages/Webkul/Admin/src/Resources/lang/en/app.php +++ b/packages/Webkul/Admin/src/Resources/lang/en/app.php @@ -99,8 +99,51 @@ return [ 'method-error' => 'Error! Wrong method detected, please check mass action configuration', 'delete-success' => 'Selected index of :resource were successfully deleted', 'partial-action' => 'Some actions were not performed due restricted system constraints on :resource', - 'update-success' => 'Selected index of :resource were successfully updated' - ] + 'update-success' => 'Selected index of :resource were successfully updated', + ], + + 'id' => 'ID', + 'status' => 'Status', + 'code' => 'Code', + 'admin-name' => 'Name', + 'name' => 'Name', + 'fullname' => 'Full Name', + 'type' => 'Type', + 'required' => 'Required', + 'unique' => 'Unique', + 'per-locale' => 'Locale Based', + 'per-channel' => 'Channel Based', + 'position' => 'Position', + 'locale' => 'Locale', + 'hostname' => 'Hostname', + 'email' => 'Email', + 'group' => 'Group', + 'title' => 'Title', + 'comment' => 'Comment', + 'product-name' => 'Product', + 'currency-name' => 'Currency Name', + 'exch-rate' => 'Exchange Rate', + 'priority' => 'Priority', + 'subscribed' => 'Subscribed', + 'base-total' => 'Base Total', + 'grand-total' => 'Grand Total', + 'order-date' => 'Order Date', + 'channel-name' => 'Channel Name', + 'billed-to' => 'Billed To', + 'order-id' => 'Order Id', + 'invoice-date' => 'Invoice Date', + 'total-qty' => 'Total Qty', + 'inventory-source' => 'Inventory Source', + 'shipment-date' => 'Shipment Date', + 'shipment-to' => 'Shipping To', + 'sku' => 'SKU', + 'price' => 'Price', + 'qty' => 'Quantity', + 'permission-type' => 'Permission Type', + 'identifier' => 'Identifier', + 'state' => 'State', + 'country' => 'Country', + 'tax-rate' => 'Rate' ], 'account' => [ diff --git a/packages/Webkul/Customer/src/Http/Controllers/RegistrationController.php b/packages/Webkul/Customer/src/Http/Controllers/RegistrationController.php index 947be1eaa..e547ad7ec 100755 --- a/packages/Webkul/Customer/src/Http/Controllers/RegistrationController.php +++ b/packages/Webkul/Customer/src/Http/Controllers/RegistrationController.php @@ -67,7 +67,7 @@ class RegistrationController extends Controller $data['channel_id'] = core()->getCurrentChannel()->id; - $data['is_verified'] = 0; + $data['is_verified'] = 1; $data['customer_group_id'] = 1; diff --git a/packages/Webkul/Customer/src/Models/Customer.php b/packages/Webkul/Customer/src/Models/Customer.php index a7b8bd97a..1f4c2c0ba 100755 --- a/packages/Webkul/Customer/src/Models/Customer.php +++ b/packages/Webkul/Customer/src/Models/Customer.php @@ -17,7 +17,7 @@ class Customer extends Authenticatable protected $table = 'customers'; - protected $fillable = ['first_name', 'channel_id', 'last_name', 'gender', 'date_of_birth', 'email', 'password', 'customer_group_id', 'subscribed_to_news_letter', 'is_verified', 'token', 'phone']; + protected $fillable = ['first_name', 'channel_id', 'last_name', 'gender', 'date_of_birth', 'email', 'password', 'customer_group_id', 'subscribed_to_news_letter', 'is_verified', 'token']; protected $hidden = ['password', 'remember_token']; diff --git a/packages/Webkul/Product/src/Http/Controllers/ProductController.php b/packages/Webkul/Product/src/Http/Controllers/ProductController.php index 619da0939..293a33761 100755 --- a/packages/Webkul/Product/src/Http/Controllers/ProductController.php +++ b/packages/Webkul/Product/src/Http/Controllers/ProductController.php @@ -203,7 +203,6 @@ class ProductController extends Controller */ public function massDestroy() { - dd(request()->input()); $productIds = explode(',', request()->input('indexes')); foreach ($productIds as $productId) { @@ -222,7 +221,6 @@ class ProductController extends Controller */ public function massUpdate() { - dd(request()->input()); $data = request()->all(); if (!isset($data['massaction-type'])) { diff --git a/packages/Webkul/Ui/src/DataGrid/DataGrid.php b/packages/Webkul/Ui/src/DataGrid/DataGrid.php index b002af5b0..a8c579ef1 100644 --- a/packages/Webkul/Ui/src/DataGrid/DataGrid.php +++ b/packages/Webkul/Ui/src/DataGrid/DataGrid.php @@ -5,16 +5,16 @@ namespace Webkul\Ui\DataGrid; use Illuminate\Http\Request; /** - * Product Data Grid class + * DataGrid class * - * @author Jitendra Singh + * @author Prashant Singh @prashant-webkul * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) */ abstract class DataGrid { protected $index = null; protected $columns = []; - protected $allColumns = []; + protected $completeColumnDetails = []; protected $queryBuilder = []; protected $collection = []; protected $actions = []; @@ -22,13 +22,11 @@ abstract class DataGrid protected $request; protected $parse; protected $enableMassAction = false; - protected $itemsPerPage = 0; + protected $enableAction = false; + protected $itemsPerPage = 10; - abstract public function prepareMassActions(); - abstract public function prepareActions(); abstract public function prepareQueryBuilder(); abstract public function addColumns(); - abstract public function setIndex(); /** * Parse the URL and get it ready to be used. @@ -52,12 +50,12 @@ abstract class DataGrid { array_push($this->columns, $column); - $this->setAllColumnDetails($column); + $this->setCompleteColumnDetails($column); } - public function setAllColumnDetails($column) + public function setCompleteColumnDetails($column) { - array_push($this->allColumns, $column); + array_push($this->completeColumnDetails, $column); } public function setQueryBuilder($queryBuilder) @@ -68,6 +66,8 @@ abstract class DataGrid public function addAction($action) { array_push($this->actions, $action); + + $this->enableAction = true; } public function addMassAction($massAction) @@ -84,15 +84,18 @@ abstract class DataGrid if(count($parsedUrl)) { $filteredOrSortedCollection = $this->sortOrFilterCollection($this->collection = $this->queryBuilder, $parsedUrl); - if($this->itemsPerPage > 0) { - return $filteredOrSortedCollection->paginate($this->itemsPerPage)->appends(request()->except('page')); + if(config('datagrid.paginate')) { + if($this->itemsPerPage > 0) + return $filteredOrSortedCollection->paginate($this->itemsPerPage)->appends(request()->except('page')); } else { return $filteredOrSortedCollection->get(); } } - if ($this->itemsPerPage > 0) { - $this->collection = $this->queryBuilder->paginate($this->itemsPerPage)->appends(request()->except('page')); + if(config('datagrid.paginate')) { + if ($this->itemsPerPage > 0) { + $this->collection = $this->queryBuilder->paginate($this->itemsPerPage)->appends(request()->except('page')); + } } else { $this->collection = $this->queryBuilder->get(); } @@ -107,8 +110,8 @@ abstract class DataGrid */ public function findColumnType($columnAlias) { - foreach($this->allColumns as $column) { - if($column['alias'] == $columnAlias) { + foreach($this->completeColumnDetails as $column) { + if($column['index'] == $columnAlias) { return [$column['type'], $column['index']]; } } @@ -142,7 +145,7 @@ abstract class DataGrid if($count_keys == 1) { return $collection->where(function() use($collection, $info) { - foreach ($this->allColumns as $column) { + foreach ($this->completeColumnDetails as $column) { if($column['searchable'] == true) $collection->orWhere($column['index'], 'like', '%'.$info['all'].'%'); } @@ -182,14 +185,12 @@ abstract class DataGrid { $this->addColumns(); - $this->setIndex(); - $this->prepareActions(); $this->prepareMassActions(); $this->prepareQueryBuilder(); - return view('ui::datagrid.table')->with('results', ['records' => $this->getCollection(), 'columns' => $this->allColumns, 'actions' => $this->actions, 'massactions' => $this->massActions, 'index' => $this->index, 'enableMassActions' => $this->enableMassAction, 'norecords' => trans('ui::datagrid.no-records')]); + 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')]); } } \ No newline at end of file diff --git a/packages/Webkul/Ui/src/Resources/views/datagrid/body.blade.php b/packages/Webkul/Ui/src/Resources/views/datagrid/body.blade.php index 7c20ee2be..f6caa5f8b 100644 --- a/packages/Webkul/Ui/src/Resources/views/datagrid/body.blade.php +++ b/packages/Webkul/Ui/src/Resources/views/datagrid/body.blade.php @@ -1,43 +1,51 @@ - @foreach($records as $key => $record) - - @if($enableMassAction) - - - + @if(count($records)) + @foreach($records as $key => $record) + + @if($enableMassActions) + + + - - - - @endif - - @foreach($columns as $column) - @php - $columnIndex = explode('.', $column['index']); - - $columnIndex = end($columnIndex); - @endphp - - @if(isset($column['wrapper'])) - @if(isset($column['closure']) && $column['closure'] == true) - {!! $column['wrapper']($record->{$columnIndex}) !!} - @else - {{ $column['wrapper']($record->{$columnIndex}) }} - @endif - @else - {{ $record->{$columnIndex} }} + + + @endif - @endforeach - -
- @foreach($actions as $action) - - - - @endforeach -
- + @foreach($columns as $column) + @php + $columnIndex = explode('.', $column['index']); + + $columnIndex = end($columnIndex); + @endphp + + @if(isset($column['wrapper'])) + @if(isset($column['closure']) && $column['closure'] == true) + {!! $column['wrapper']($record->{$columnIndex}) !!} + @else + {{ $column['wrapper']($record->{$columnIndex}) }} + @endif + @else + {{ $record->{$columnIndex} }} + @endif + @endforeach + + @if($enableActions) + +
+ @foreach($actions as $action) + + + + @endforeach +
+ + @endif + + @endforeach + @else + + {{$norecords}} - @endforeach + @endif \ 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 a3ba2831f..5d02e4d63 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.pagination')) + @if(config('datagrid.paginate')) @include('ui::datagrid.pagination', ['results' => $results['records']]) @endif @@ -35,7 +35,7 @@ - +
@@ -185,7 +185,7 @@ - @if($results['enableMassActions']) + @if(count($results['records']) && $results['enableMassActions']) @@ -196,18 +196,20 @@ @endif @foreach($results['columns'] as $key => $column) - + {{ $column['label'] }} @endforeach - - Actions - + @if($results['enableActions']) + + {{ __('ui::app.datagrid.actions') }} + + @endif - @include('ui::datagrid.body', ['records' => $results['records'], 'actions' => $results['actions'], 'index' => $results['index'], 'columns' => $results['columns'],'enableMassAction' => $results['enableMassActions']]) + @include('ui::datagrid.body', ['records' => $results['records'], 'actions' => $results['actions'], 'index' => $results['index'], 'columns' => $results['columns'],'enableMassActions' => $results['enableMassActions'], 'enableActions' => $results['enableActions'], 'norecords' => $results['norecords']]) @@ -265,7 +267,7 @@ this.columnOrAlias = columnOrAlias; for(column in this.columns) { - if (this.columns[column].alias == this.columnOrAlias) { + if (this.columns[column].index == this.columnOrAlias) { this.type = this.columns[column].type; if(this.type == 'string') { @@ -312,7 +314,7 @@ label = ''; for(colIndex in this.columns) { - if(this.columns[colIndex].alias == this.columnOrAlias) { + if(this.columns[colIndex].index == this.columnOrAlias) { label = this.columns[colIndex].label; } } @@ -332,7 +334,7 @@ label = ''; for(colIndex in this.columns) { - if(this.columns[colIndex].alias == this.columnOrAlias) { + if(this.columns[colIndex].index == this.columnOrAlias) { label = this.columns[colIndex].label; } } @@ -344,7 +346,7 @@ label = ''; for(colIndex in this.columns) { - if(this.columns[colIndex].alias == this.columnOrAlias) { + if(this.columns[colIndex].index == this.columnOrAlias) { label = this.columns[colIndex].label; } } @@ -602,7 +604,7 @@ label = ''; for(colIndex in this.columns) { - if(this.columns[colIndex].alias == obj.cond) { + if(this.columns[colIndex].index == obj.cond) { obj.label = this.columns[colIndex].label; } } @@ -612,7 +614,7 @@ obj.label = ''; for(colIndex in this.columns) { - if(this.columns[colIndex].alias == obj.column) { + if(this.columns[colIndex].index == obj.column) { obj.label = this.columns[colIndex].label; } } diff --git a/tests/Feature/Auth/AuthTest.php b/tests/Feature/Auth/AuthTest.php new file mode 100644 index 000000000..1996cedbc --- /dev/null +++ b/tests/Feature/Auth/AuthTest.php @@ -0,0 +1,75 @@ + 'http://127.0.0.1:8000']); + + $response = $this->get('/customer/login'); + + $response->assertSuccessful(); + + $response->assertViewIs('shop::customers.session.index'); + } + + public function testCustomerResgistrationPage() { + config(['app.url' => 'http://127.0.0.1:8000']); + + $response = $this->get('/customer/register'); + + $response->assertSuccessful(); + + $response->assertViewIs('shop::customers.signup.index'); + } + + public function testCustomerRegistration() { + $faker = \Faker\Factory::create(); + + $allCustomers = array(); + + $customers = app(Customer::class); + + $created = $customers->create([ + 'first_name' => explode(' ',$faker->name)[0], + 'last_name' => explode(' ',$faker->name)[0], + 'channel_id' => core()->getCurrentChannel()->id, + 'gender' => $faker->randomElement($array = array ('Male','Female', 'Other')), + 'date_of_birth' => $faker->date($format = 'Y-m-d', $max = 'now'), + 'email' => $faker->email, + 'password' => bcrypt('12345678'), + 'is_verified' => 1 + ]); + + $this->assertEquals($created->id, $created->id); + } + + public function testCustomerLogin() { + $customers = app(Customer::class); + + $customer = $customers->find(1); + + $user = ['email' => $customer->email, 'password' => $customer->password]; + + $this->assertAuthenticatedAs($user); + } +} diff --git a/tests/Feature/ExampleTest.php b/tests/Feature/ExampleTest.php deleted file mode 100755 index f31e495ca..000000000 --- a/tests/Feature/ExampleTest.php +++ /dev/null @@ -1,21 +0,0 @@ -get('/'); - - $response->assertStatus(200); - } -} diff --git a/tests/Feature/GeneralTest.php b/tests/Feature/GeneralTest.php new file mode 100644 index 000000000..b11a14949 --- /dev/null +++ b/tests/Feature/GeneralTest.php @@ -0,0 +1,87 @@ + 'http://127.0.0.1:8000']); + + $response = $this->get('/'); + + $response->assertStatus(200); + } + + /** + * Test for customer login + * + * @return void + */ + public function testCustomerLoginPage() + { + config(['app.url' => 'http://127.0.0.1:8000']); + + $response = $this->get('/customer/login'); + + $response->assertStatus(200); + } + + /** + * Test for categories page + * + * @return void + */ + public function testCategoriesPage() + { + $categoryUrlSlug = 'marvel-figurines'; + + config(['app.url' => 'http://127.0.0.1:8000']); + + $response = $this->get("/categories/{$categoryUrlSlug}"); + + $response->assertStatus(200); + } + + /** + * Test for customer registration page + * + * @return void + */ + public function testCustomerRegistrationPage() + { + config(['app.url' => 'http://127.0.0.1:8000']); + + $response = $this->get("/customer/register"); + + $response->assertStatus(200); + } + + /** + * Test for checkout's cart page + * + * @return void + */ + public function testCartPage() + { + config(['app.url' => 'http://127.0.0.1:8000']); + + $response = $this->get("/checkout/cart"); + + $response->assertStatus(200); + } +} \ No newline at end of file