Merge pull request #19 from jitendra-webkul/prashant

Prashant
This commit is contained in:
JItendra Singh 2018-08-10 10:20:30 +05:30 committed by GitHub
commit 08b49ae2b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
73 changed files with 3439 additions and 563 deletions

1
.gitignore vendored
View File

@ -14,3 +14,4 @@ Homestead.yaml
npm-debug.log
yarn-error.log
.env
/ignorables/*

View File

@ -11,6 +11,7 @@
"php": "^7.1.3",
"dimsav/laravel-translatable": "^9.0",
"fideloper/proxy": "^4.0",
"intervention/image": "^2.4",
"kalnoy/nestedset": "^4.3",
"laravel/framework": "5.6.*",
"laravel/tinker": "^1.0",

187
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "daaa24e649dd4e9808feef8251e43247",
"content-hash": "8acd4eec85be1351459a67cfd14d039b",
"packages": [
{
"name": "commerceguys/intl",
@ -465,6 +465,141 @@
],
"time": "2018-02-07T20:20:57+00:00"
},
{
"name": "guzzlehttp/psr7",
"version": "1.4.2",
"source": {
"type": "git",
"url": "https://github.com/guzzle/psr7.git",
"reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/psr7/zipball/f5b8a8512e2b58b0071a7280e39f14f72e05d87c",
"reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c",
"shasum": ""
},
"require": {
"php": ">=5.4.0",
"psr/http-message": "~1.0"
},
"provide": {
"psr/http-message-implementation": "1.0"
},
"require-dev": {
"phpunit/phpunit": "~4.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.4-dev"
}
},
"autoload": {
"psr-4": {
"GuzzleHttp\\Psr7\\": "src/"
},
"files": [
"src/functions_include.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
},
{
"name": "Tobias Schultze",
"homepage": "https://github.com/Tobion"
}
],
"description": "PSR-7 message implementation that also provides common utility methods",
"keywords": [
"http",
"message",
"request",
"response",
"stream",
"uri",
"url"
],
"time": "2017-03-20T17:10:46+00:00"
},
{
"name": "intervention/image",
"version": "2.4.2",
"source": {
"type": "git",
"url": "https://github.com/Intervention/image.git",
"reference": "e82d274f786e3d4b866a59b173f42e716f0783eb"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Intervention/image/zipball/e82d274f786e3d4b866a59b173f42e716f0783eb",
"reference": "e82d274f786e3d4b866a59b173f42e716f0783eb",
"shasum": ""
},
"require": {
"ext-fileinfo": "*",
"guzzlehttp/psr7": "~1.1",
"php": ">=5.4.0"
},
"require-dev": {
"mockery/mockery": "~0.9.2",
"phpunit/phpunit": "^4.8 || ^5.7"
},
"suggest": {
"ext-gd": "to use GD library based image processing.",
"ext-imagick": "to use Imagick based image processing.",
"intervention/imagecache": "Caching extension for the Intervention Image library"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.4-dev"
},
"laravel": {
"providers": [
"Intervention\\Image\\ImageServiceProvider"
],
"aliases": {
"Image": "Intervention\\Image\\Facades\\Image"
}
}
},
"autoload": {
"psr-4": {
"Intervention\\Image\\": "src/Intervention/Image"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Oliver Vogel",
"email": "oliver@olivervogel.com",
"homepage": "http://olivervogel.com/"
}
],
"description": "Image handling and manipulation library with support for Laravel integration",
"homepage": "http://image.intervention.io/",
"keywords": [
"gd",
"image",
"imagick",
"laravel",
"thumbnail",
"watermark"
],
"time": "2018-05-29T14:19:03+00:00"
},
{
"name": "jakub-onderka/php-console-color",
"version": "0.1",
@ -1371,6 +1506,56 @@
],
"time": "2017-02-14T16:28:37+00:00"
},
{
"name": "psr/http-message",
"version": "1.0.1",
"source": {
"type": "git",
"url": "https://github.com/php-fig/http-message.git",
"reference": "f6561bf28d520154e4b0ec72be95418abe6d9363"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363",
"reference": "f6561bf28d520154e4b0ec72be95418abe6d9363",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\Http\\Message\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
}
],
"description": "Common interface for HTTP messages",
"homepage": "https://github.com/php-fig/http-message",
"keywords": [
"http",
"http-message",
"psr",
"psr-7",
"request",
"response"
],
"time": "2016-08-06T14:39:51+00:00"
},
{
"name": "psr/log",
"version": "1.0.2",

View File

@ -170,6 +170,9 @@ return [
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
//Laravel Intervention
Intervention\Image\ImageServiceProvider::class,
//Webkul packages
Webkul\User\Providers\UserServiceProvider::class,
Webkul\Admin\Providers\AdminServiceProvider::class,
@ -232,7 +235,8 @@ return [
'URL' => Illuminate\Support\Facades\URL::class,
'Validator' => Illuminate\Support\Facades\Validator::class,
'View' => Illuminate\Support\Facades\View::class,
'Datagrid' => Webkul\Ui\DataGrid\Facades\DataGrid::class
'Datagrid' => Webkul\Ui\DataGrid\Facades\DataGrid::class,
'Image' => Intervention\Image\Facades\Image::class
],
];

20
config/image.php Normal file
View File

@ -0,0 +1,20 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Image Driver
|--------------------------------------------------------------------------
|
| Intervention Image supports "GD Library" and "Imagick" to process images
| internally. You may choose one of them according to your PHP
| configuration. By default PHP's "GD Library" implementation is used.
|
| Supported: "gd", "imagick"
|
*/
'driver' => 'gd'
];

View File

@ -22,120 +22,73 @@ class DataGridController extends Controller
*/
public function index()
{
// $select_verbs = [
// 0 => "aggregate",
// 1 => "columns",
// 2 => "from",
// 3 => "joins",
// 4 => "wheres",
// 5 => "groups",
// 6 => "havings",
// 7 => "orders",
// 8 => "limit",
// 9 => "offset",
// 10 => "lock"
// ];
// $bindings = [
// "select" => [],
// "from" => [],
// "join" => [],
// "where" => [],
// "having" => [],
// "order" => [],
// "union" => [],
// ];
// $operators = [
// 'eq' => "=",
// 'lt' => "<",
// 'gt' => ">",
// 'lte' => "<=",
// 'gte' => ">=",
// 'neqs' => "<>",
// 'neqn' => "!=",
// 'ceq' => "<=>",
// 'like' => "like",
// 'likebin' => "like binary",
// 'ntlike' => "not like",
// 'ilike' => "ilike",
// 'regex' => "regexp",
// 'notregex' => "not regexp",
// 'simto' => "similar to",
// 'nsimto' => "not similar to",
// 'nilike' => "not ilike",
// ];
DataGrid::make([
'name' => 'authors',
'table' => 'authors as a',
'select' => 'a.id',
'name' => 'Admin Datagrid',
'table' => 'admins as u',
'select' => 'u.id',
'aliased' => true , //boolean to validate aliasing on the basis of this.
'perpage' => 2,
'filterable' => [
[
'column' => 'a.id',
'column' => 'u.id',
'type' => 'integer',
'label' => 'Admin ID'
], [
'column' => 'a.email',
'column' => 'u.email',
'type' => 'string',
'label' => 'Admin E-Mail',
], [
'column' => 'a.first_name',
'column' => 'u.name',
'type' => 'string',
'label' => 'Admin Name',
]
],
'searchables' =>[
[
'name' => 'a.id',
'name' => 'u.id',
'label' => 'ID',
'label' => 'Admin ID',
],
[
'name' => 'a.name',
'name' => 'u.name',
'label' => 'Name',
'label' => 'Admin Name',
]
],
'join' => [
// [
// 'join' => 'leftjoin',
// 'table' => 'posts as p',
// 'primaryKey' => 'a.id',
// 'condition' => '=',
// 'secondaryKey' => 'p.author_id',
// ]
[
'join' => 'leftjoin',
'table' => 'roles as r',
'primaryKey' => 'u.role_id',
'condition' => '=',
'secondaryKey' => 'r.id',
]
],
'columns' => [
[
'name' => 'a.id',
'name' => 'u.id',
'type' => 'string',
'label' => 'Admin ID',
'sortable' => true,
'filterable' => true
],
[
'name' => 'a.email',
'name' => 'u.email',
'type' => 'string',
'label' => 'Admin E-Mail',
'sortable' => true,
'filterable' => true
],
// [
// 'name' => 'p.content as pp',
// 'type' => 'string',
// 'label' => 'Content',
// 'sortable' => true,
// 'filterable' => false,
// ],
[
'name' => 'a.first_name',
'name' => 'u.name',
'type' => 'string',
'label' => 'Admin Name',
'sortable' => true,
'filterable' => true,
// will create on run time query
// 'filter' => [
// 'function' => 'where', // orwhere
// 'condition' => ['name', '=', 'Admin'] // multiarray
// 'function' => 'orwhere', // orwhere
// 'condition' => ['name', 'like', 'u'] // multiarray
// ],
'attributes' => [
'class' => 'class-a class-b',
@ -143,10 +96,23 @@ class DataGridController extends Controller
'onclick' => "window.alert('alert from datagrid column')"
],
'wrapper' => function ($value, $object) {
return '<a href="'.$value.'">' . $object->first_name . '</a>';
return '<a href="'.$value.'">' . $object->name . '</a>';
},
],
[
'name' => 'r.name as x',
'type' => 'string',
'label' => 'Admin\'s Role',
'sortable' => true,
'filterable' => true,
],
[
'name' => 'r.id as xx',
'type' => 'integer',
'label' => 'Role ID',
'sortable' => false,
'filterable' => false
],
],
'operators' => [
@ -174,13 +140,6 @@ class DataGridController extends Controller
]);
$result = DataGrid::render();
return $result;
// $prepareMassAction = DataGrid::massAction();
// if ($prepareMassAction) {
// $result = DataGrid::render();
// return $result;
// } else {
// throw new \Exception('Mass Actions Attributes Have Some Unknown Problems');
// }
}
//for performing mass actions
@ -213,7 +172,6 @@ class DataGridController extends Controller
]
];
$result = DataGrid::makeMassAction($make);
// return $result;
}
public function massDelete(Request $r)

View File

@ -0,0 +1,154 @@
<?php
namespace Webkul\Admin\Http\ViewComposers\DataGrids;
use Illuminate\View\View;
use Webkul\Ui\DataGrid\Facades\DataGrid;
// use App\Repositories\UserRepository;
class ChannelsComposer
{
/**
* The Data Grid implementation.
*
* @var CountryComposer
* for countries
*/
/**
* Bind data to the view.
*
* @param View $view
* @return void
*/
public function compose(View $view)
{
$datagrid = DataGrid::make([
'name' => 'Channels',
'table' => 'channels',
'select' => 'id',
'perpage' => 5,
'aliased' => false, //use this with false as default and true in case of joins
'massoperations' =>[
[
'route' => route('admin.datagrid.delete'),
'method' => 'DELETE',
'label' => 'Delete',
'type' => 'button',
],
],
'actions' => [
[
'type' => 'Edit',
'route' => route('admin.datagrid.delete'),
'confirm_text' => 'Do you really edit this record?',
'icon' => 'icon pencil-lg-icon',
], [
'type' => 'Delete',
'route' => route('admin.datagrid.delete'),
'confirm_text' => 'Do you really want to delete this record?',
'icon' => 'icon trash-icon',
],
],
'join' => [
// [
// 'join' => 'leftjoin',
// 'table' => 'roles as r',
// 'primaryKey' => 'u.role_id',
// 'condition' => '=',
// 'secondaryKey' => 'r.id',
// ]
],
//use aliasing on secodary columns if join is performed
'columns' => [
[
'name' => 'id',
'alias' => 'channel_id',
'type' => 'number',
'label' => 'Channel ID',
'sortable' => true,
],
[
'name' => 'code',
'alias' => 'channel_code',
'type' => 'string',
'label' => 'Channel Code',
'sortable' => true,
],
[
'name' => 'name',
'alias' => 'channel_name',
'type' => 'string',
'label' => 'Channel Name',
'sortable' => true,
],
],
//don't use aliasing in case of filters
'filterable' => [
[
'column' => 'id',
'alias' => 'channel_id',
'type' => 'number',
'label' => 'Channel ID',
],
[
'column' => 'code',
'alias' => 'channel_code',
'type' => 'string',
'label' => 'Channel Code',
],
[
'column' => 'name',
'alias' => 'channel_name',
'type' => 'string',
'label' => 'Channel Name',
],
],
//don't use aliasing in case of searchables
'searchable' => [
[
'column' => 'name',
'type' => 'string',
'label' => 'Channel Name',
],
[
'column' => 'code',
'type' => 'string',
'label' => 'Channel Code',
],
],
//list of viable operators that will be used
'operators' => [
'eq' => "=",
'lt' => "<",
'gt' => ">",
'lte' => "<=",
'gte' => ">=",
'neqs' => "<>",
'neqn' => "!=",
'like' => "like",
'nlike' => "not like",
],
// 'css' => []
]);
$view->with('datagrid', $datagrid);
// $view->with('count', $this->users->count());
}
}

View File

@ -0,0 +1,167 @@
<?php
namespace Webkul\Admin\Http\ViewComposers\DataGrids;
use Illuminate\View\View;
use Webkul\Ui\DataGrid\Facades\DataGrid;
// use App\Repositories\UserRepository;
class CountryComposer
{
/**
* The Data Grid implementation.
*
* @var CountryComposer
* for countries
*/
/**
* Bind data to the view.
*
* @param View $view
* @return void
*/
public function compose(View $view)
{
$datagrid = DataGrid::make([
'name' => 'Countries',
'table' => 'countries',
'select' => 'id',
'perpage' => 10,
'aliased' => false, //use this with false as default and true in case of joins
'massoperations' =>[
[
'route' => route('admin.datagrid.delete'),
'method' => 'DELETE',
'label' => 'Delete',
'type' => 'button',
],
],
'actions' => [
[
'type' => 'Edit',
'route' => route('admin.datagrid.delete'),
'confirm_text' => 'Do you really want to do this?',
'icon' => 'icon pencil-lg-icon',
], [
'type' => 'Delete',
'route' => route('admin.datagrid.delete'),
'confirm_text' => 'Do you really want to do this?',
'icon' => 'icon trash-icon',
],
],
'join' => [
// [
// 'join' => 'leftjoin',
// 'table' => 'roles as r',
// 'primaryKey' => 'u.role_id',
// 'condition' => '=',
// 'secondaryKey' => 'r.id',
// ]
],
//use aliasing on secodary columns if join is performed
'columns' => [
[
'name' => 'id',
'alias' => 'country_id',
'type' => 'number',
'label' => 'ID',
'sortable' => true,
],
[
'name' => 'code',
'alias' => 'country_code',
'type' => 'string',
'label' => 'Code',
'sortable' => true,
],
[
'name' => 'name',
'alias' => 'country_name',
'type' => 'string',
'label' => 'Name',
'sortable' => true,
],
[
'name' => 'status',
'alias' => 'country_status',
'type' => 'number',
'label' => 'Code',
'sortable' => true,
],
],
//don't use aliasing in case of filters
'filterable' => [
[
'column' => 'id',
'alias' => 'country_id',
'type' => 'number',
'label' => 'ID',
],
[
'column' => 'code',
'alias' => 'country_code',
'type' => 'string',
'label' => 'Code',
],
[
'column' => 'name',
'alias' => 'country_name',
'type' => 'string',
'label' => 'Name',
],
[
'column' => 'status',
'alias' => 'country_status',
'type' => 'number',
'label' => 'Code',
],
],
//don't use aliasing in case of searchables
'searchable' => [
[
'column' => 'name',
'type' => 'string',
'label' => 'Name',
],
[
'column' => 'code',
'type' => 'string',
'label' => 'Code',
],
],
//list of viable operators that will be used
'operators' => [
'eq' => "=",
'lt' => "<",
'gt' => ">",
'lte' => "<=",
'gte' => ">=",
'neqs' => "<>",
'neqn' => "!=",
'like' => "like",
'nlike' => "not like",
],
// 'css' => []
]);
$view->with('datagrid', $datagrid);
// $view->with('count', $this->users->count());
}
}

View File

@ -0,0 +1,154 @@
<?php
namespace Webkul\Admin\Http\ViewComposers\DataGrids;
use Illuminate\View\View;
use Webkul\Ui\DataGrid\Facades\DataGrid;
// use App\Repositories\UserRepository;
class CurrenciesComposer
{
/**
* The Data Grid implementation.
*
* @var CountryComposer
* for countries
*/
/**
* Bind data to the view.
*
* @param View $view
* @return void
*/
public function compose(View $view)
{
$datagrid = DataGrid::make([
'name' => 'Currencies',
'table' => 'currencies',
'select' => 'id',
'perpage' => 5,
'aliased' => false, //use this with false as default and true in case of joins
'massoperations' =>[
[
'route' => route('admin.datagrid.delete'),
'method' => 'DELETE',
'label' => 'Delete',
'type' => 'button',
],
],
'actions' => [
[
'type' => 'Edit',
'route' => route('admin.datagrid.delete'),
'confirm_text' => 'Do you really edit this record?',
'icon' => 'icon pencil-lg-icon',
], [
'type' => 'Delete',
'route' => route('admin.datagrid.delete'),
'confirm_text' => 'Do you really want to delete this record?',
'icon' => 'icon trash-icon',
],
],
'join' => [
// [
// 'join' => 'leftjoin',
// 'table' => 'roles as r',
// 'primaryKey' => 'u.role_id',
// 'condition' => '=',
// 'secondaryKey' => 'r.id',
// ]
],
//use aliasing on secodary columns if join is performed
'columns' => [
[
'name' => 'id',
'alias' => 'currency_id',
'type' => 'number',
'label' => 'ID',
'sortable' => true,
],
[
'name' => 'code',
'alias' => 'currency_code',
'type' => 'string',
'label' => 'Code',
'sortable' => true,
],
[
'name' => 'name',
'alias' => 'currency_name',
'type' => 'string',
'label' => 'Name',
'sortable' => true,
],
],
//don't use aliasing in case of filters
'filterable' => [
[
'column' => 'id',
'alias' => 'currency_id',
'type' => 'number',
'label' => 'ID',
],
[
'column' => 'code',
'alias' => 'currency_code',
'type' => 'string',
'label' => 'Code',
],
[
'column' => 'name',
'alias' => 'currency_name',
'type' => 'string',
'label' => 'Name',
],
],
//don't use aliasing in case of searchables
'searchable' => [
[
'column' => 'name',
'type' => 'string',
'label' => 'Name',
],
[
'column' => 'code',
'type' => 'string',
'label' => 'Code',
],
],
//list of viable operators that will be used
'operators' => [
'eq' => "=",
'lt' => "<",
'gt' => ">",
'lte' => "<=",
'gte' => ">=",
'neqs' => "<>",
'neqn' => "!=",
'like' => "like",
'nlike' => "not like",
],
// 'css' => []
]);
$view->with('datagrid', $datagrid);
// $view->with('count', $this->users->count());
}
}

View File

@ -0,0 +1,162 @@
<?php
namespace Webkul\Admin\Http\ViewComposers\DataGrids;
use Illuminate\View\View;
use Webkul\Ui\DataGrid\Facades\DataGrid;
// use App\Repositories\UserRepository;
class ExchangeRatesComposer
{
/**
* The Data Grid implementation.
*
* @var CountryComposer
* for countries
*/
/**
* Bind data to the view.
*
* @param View $view
* @return void
*/
public function compose(View $view)
{
$datagrid = DataGrid::make([
'name' => 'Exchange Rates',
'table' => 'currency_exchange_rates',
'select' => 'id',
'perpage' => 5,
'aliased' => false, //use this with false as default and true in case of joins
'massoperations' =>[
[
'route' => route('admin.datagrid.delete'),
'method' => 'DELETE',
'label' => 'Delete',
'type' => 'button',
],
],
'actions' => [
[
'type' => 'Edit',
'route' => route('admin.datagrid.delete'),
'confirm_text' => 'Do you really edit this record?',
'icon' => 'icon pencil-lg-icon',
], [
'type' => 'Delete',
'route' => route('admin.datagrid.delete'),
'confirm_text' => 'Do you really want to delete this record?',
'icon' => 'icon trash-icon',
],
],
'join' => [
// [
// 'join' => 'leftjoin',
// 'table' => 'roles as r',
// 'primaryKey' => 'u.role_id',
// 'condition' => '=',
// 'secondaryKey' => 'r.id',
// ]
],
//use aliasing on secodary columns if join is performed
'columns' => [
[
'name' => 'id',
'alias' => 'exch_id',
'type' => 'number',
'label' => 'Rate ID',
'sortable' => true,
],
[
'name' => 'source_currency',
'alias' => 'exch_source_currency',
'type' => 'string',
'label' => 'Source Currency',
'sortable' => true,
],
[
'name' => 'target_currency',
'alias' => 'exch_target_currency',
'type' => 'string',
'label' => 'Target Currency',
'sortable' => true,
],
[
'name' => 'ratio',
'alias' => 'exch_ratio',
'type' => 'string',
'label' => 'Exchange Ratio',
],
],
//don't use aliasing in case of filters
'filterable' => [
[
'column' => 'id',
'alias' => 'exch_id',
'type' => 'number',
'label' => 'Rate ID',
],
[
'column' => 'source_currency',
'alias' => 'exch_source_currency',
'type' => 'string',
'label' => 'Source Currency',
'sortable' => true,
],
[
'column' => 'target_currency',
'alias' => 'exch_target_currency',
'type' => 'string',
'label' => 'Target Currency',
'sortable' => true,
],
],
//don't use aliasing in case of searchables
'searchable' => [
[
'column' => 'source_currency',
'type' => 'string',
'label' => 'Source Currency',
],
[
'column' => 'target_currency',
'type' => 'string',
'label' => 'Target Currency',
],
],
//list of viable operators that will be used
'operators' => [
'eq' => "=",
'lt' => "<",
'gt' => ">",
'lte' => "<=",
'gte' => ">=",
'neqs' => "<>",
'neqn' => "!=",
'like' => "like",
'nlike' => "not like",
],
// 'css' => []
]);
$view->with('datagrid', $datagrid);
// $view->with('count', $this->users->count());
}
}

View File

@ -0,0 +1,167 @@
<?php
namespace Webkul\Admin\Http\ViewComposers\DataGrids;
use Illuminate\View\View;
use Webkul\Ui\DataGrid\Facades\DataGrid;
// use App\Repositories\UserRepository;
class InventorySourcesComposer
{
/**
* The Data Grid implementation.
*
* @var CountryComposer
* for countries
*/
/**
* Bind data to the view.
*
* @param View $view
* @return void
*/
public function compose(View $view)
{
$datagrid = DataGrid::make([
'name' => 'Inventory Sources',
'table' => 'inventory_sources',
'select' => 'id',
'perpage' => 5,
'aliased' => false, //use this with false as default and true in case of joins
'massoperations' =>[
[
'route' => route('admin.datagrid.delete'),
'method' => 'DELETE',
'label' => 'Delete',
'type' => 'button',
],
],
'actions' => [
[
'type' => 'Edit',
'route' => route('admin.datagrid.delete'),
'confirm_text' => 'Do you really edit this record?',
'icon' => 'icon pencil-lg-icon',
], [
'type' => 'Delete',
'route' => route('admin.datagrid.delete'),
'confirm_text' => 'Do you really want to delete this record?',
'icon' => 'icon trash-icon',
],
],
'join' => [
// [
// 'join' => 'leftjoin',
// 'table' => 'roles as r',
// 'primaryKey' => 'u.role_id',
// 'condition' => '=',
// 'secondaryKey' => 'r.id',
// ]
],
//use aliasing on secodary columns if join is performed
'columns' => [
[
'name' => 'id',
'alias' => 'inventory_id',
'type' => 'number',
'label' => 'ID',
'sortable' => true,
],
[
'name' => 'code',
'alias' => 'inventory_code',
'type' => 'string',
'label' => 'Code',
'sortable' => true,
],
[
'name' => 'name',
'alias' => 'inventory_name',
'type' => 'string',
'label' => 'Name',
'sortable' => true,
],
[
'name' => 'priority',
'alias' => 'inventory_priority',
'type' => 'string',
'label' => 'Priority',
'sortable' => true,
],
[
'name' => 'status',
'alias' => 'inventory_status',
'type' => 'string',
'label' => 'Status',
'sortable' => true,
],
],
//don't use aliasing in case of filters
'filterable' => [
[
'column' => 'id',
'alias' => 'inventory_id',
'type' => 'number',
'label' => 'ID',
],
[
'column' => 'code',
'alias' => 'inventory_code',
'type' => 'string',
'label' => 'Code',
],
[
'column' => 'name',
'alias' => 'inventory_name',
'type' => 'string',
'label' => 'Name',
],
],
//don't use aliasing in case of searchables
'searchable' => [
[
'column' => 'name',
'type' => 'string',
'label' => 'Name',
],
[
'column' => 'code',
'type' => 'string',
'label' => 'Code',
],
],
//list of viable operators that will be used
'operators' => [
'eq' => "=",
'lt' => "<",
'gt' => ">",
'lte' => "<=",
'gte' => ">=",
'neqs' => "<>",
'neqn' => "!=",
'like' => "like",
'nlike' => "not like",
],
// 'css' => []
]);
$view->with('datagrid', $datagrid);
}
}

View File

@ -0,0 +1,154 @@
<?php
namespace Webkul\Admin\Http\ViewComposers\DataGrids;
use Illuminate\View\View;
use Webkul\Ui\DataGrid\Facades\DataGrid;
// use App\Repositories\UserRepository;
class LocalesComposer
{
/**
* The Data Grid implementation.
*
* @var CountryComposer
* for countries
*/
/**
* Bind data to the view.
*
* @param View $view
* @return void
*/
public function compose(View $view)
{
$datagrid = DataGrid::make([
'name' => 'Locales',
'table' => 'locales',
'select' => 'id',
'perpage' => 5,
'aliased' => false, //use this with false as default and true in case of joins
'massoperations' =>[
[
'route' => route('admin.datagrid.delete'),
'method' => 'DELETE',
'label' => 'Delete',
'type' => 'button',
],
],
'actions' => [
[
'type' => 'Edit',
'route' => route('admin.datagrid.delete'),
'confirm_text' => 'Do you really edit this record?',
'icon' => 'icon pencil-lg-icon',
], [
'type' => 'Delete',
'route' => route('admin.datagrid.delete'),
'confirm_text' => 'Do you really want to delete this record?',
'icon' => 'icon trash-icon',
],
],
'join' => [
// [
// 'join' => 'leftjoin',
// 'table' => 'roles as r',
// 'primaryKey' => 'u.role_id',
// 'condition' => '=',
// 'secondaryKey' => 'r.id',
// ]
],
//use aliasing on secodary columns if join is performed
'columns' => [
[
'name' => 'id',
'alias' => 'locale_id',
'type' => 'number',
'label' => 'ID',
'sortable' => true,
],
[
'name' => 'code',
'alias' => 'locale_code',
'type' => 'string',
'label' => 'Code',
'sortable' => true,
],
[
'name' => 'name',
'alias' => 'locale_name',
'type' => 'string',
'label' => 'Name',
'sortable' => true,
],
],
//don't use aliasing in case of filters
'filterable' => [
[
'column' => 'id',
'alias' => 'locale_id',
'type' => 'number',
'label' => 'ID',
],
[
'column' => 'code',
'alias' => 'locale_code',
'type' => 'string',
'label' => 'Code',
],
[
'column' => 'name',
'alias' => 'locale_name',
'type' => 'string',
'label' => 'Name',
],
],
//don't use aliasing in case of searchables
'searchable' => [
[
'column' => 'name',
'type' => 'string',
'label' => 'Name',
],
[
'column' => 'code',
'type' => 'string',
'label' => 'Code',
],
],
//list of viable operators that will be used
'operators' => [
'eq' => "=",
'lt' => "<",
'gt' => ">",
'lte' => "<=",
'gte' => ">=",
'neqs' => "<>",
'neqn' => "!=",
'like' => "like",
'nlike' => "not like",
],
// 'css' => []
]);
$view->with('datagrid', $datagrid);
// $view->with('count', $this->users->count());
}
}

View File

@ -0,0 +1,154 @@
<?php
namespace Webkul\Admin\Http\ViewComposers\DataGrids;
use Illuminate\View\View;
use Webkul\Ui\DataGrid\Facades\DataGrid;
// use App\Repositories\UserRepository;
class RolesComposer
{
/**
* The Data Grid implementation.
*
* @var CountryComposer
* for countries
*/
/**
* Bind data to the view.
*
* @param View $view
* @return void
*/
public function compose(View $view)
{
$datagrid = DataGrid::make([
'name' => 'Roles',
'table' => 'roles',
'select' => 'id',
'perpage' => 5,
'aliased' => false, //use this with false as default and true in case of joins
'massoperations' =>[
[
'route' => route('admin.datagrid.delete'),
'method' => 'DELETE',
'label' => 'Delete',
'type' => 'button',
],
],
'actions' => [
[
'type' => 'Edit',
'route' => route('admin.datagrid.delete'),
'confirm_text' => 'Do you really edit this record?',
'icon' => 'icon pencil-lg-icon',
], [
'type' => 'Delete',
'route' => route('admin.datagrid.delete'),
'confirm_text' => 'Do you really want to delete this record?',
'icon' => 'icon trash-icon',
],
],
'join' => [
// [
// 'join' => 'leftjoin',
// 'table' => 'roles as r',
// 'primaryKey' => 'u.role_id',
// 'condition' => '=',
// 'secondaryKey' => 'r.id',
// ]
],
//use aliasing on secodary columns if join is performed
'columns' => [
[
'name' => 'id',
'alias' => 'r_id',
'type' => 'number',
'label' => 'ID',
'sortable' => true,
],
[
'name' => 'name',
'alias' => 'r_name',
'type' => 'string',
'label' => 'Name',
'sortable' => true,
],
[
'name' => 'permission_type',
'alias' => 'r_permission_type',
'type' => 'string',
'label' => 'Permission Type',
'sortable' => true,
],
],
//don't use aliasing in case of filters
'filterable' => [
[
'column' => 'id',
'alias' => 'r_id',
'type' => 'number',
'label' => 'ID',
],
[
'column' => 'name',
'alias' => 'r_name',
'type' => 'string',
'label' => 'Name',
],
[
'column' => 'permission_type',
'alias' => 'r_permission_type',
'type' => 'string',
'label' => 'Permission Type',
],
],
//don't use aliasing in case of searchables
'searchable' => [
[
'column' => 'name',
'type' => 'string',
'label' => 'Name',
],
[
'column' => 'permission_type',
'type' => 'string',
'label' => 'Permission Type',
],
],
//list of viable operators that will be used
'operators' => [
'eq' => "=",
'lt' => "<",
'gt' => ">",
'lte' => "<=",
'gte' => ">=",
'neqs' => "<>",
'neqn' => "!=",
'like' => "like",
'nlike' => "not like",
],
// 'css' => []
]);
$view->with('datagrid', $datagrid);
// $view->with('count', $this->users->count());
}
}

View File

@ -0,0 +1,159 @@
<?php
namespace Webkul\Admin\Http\ViewComposers\DataGrids;
use Illuminate\View\View;
use Webkul\Ui\DataGrid\Facades\DataGrid;
// use App\Repositories\UserRepository;
class SliderComposer
{
/**
* The Data Grid implementation.
*
* @var CountryComposer
* for countries
*/
/**
* Bind data to the view.
*
* @param View $view
* @return void
*/
public function compose(View $view)
{
$datagrid = DataGrid::make([
'name' => 'Sliders',
'table' => 'sliders as s',
'select' => 's.id',
'perpage' => 5,
'aliased' => true, //use this with false as default and true in case of joins
'massoperations' =>[
[
'route' => route('admin.datagrid.delete'),
'method' => 'DELETE',
'label' => 'Delete',
'type' => 'button',
],
],
'actions' => [
[
'type' => 'Edit',
'route' => route('admin.datagrid.delete'),
'confirm_text' => 'Do you really edit this record?',
'icon' => 'icon pencil-lg-icon',
], [
'type' => 'Delete',
'route' => route('admin.datagrid.delete'),
'confirm_text' => 'Do you really want to delete this record?',
'icon' => 'icon trash-icon',
],
],
'join' => [
[
'join' => 'leftjoin',
'table' => 'channels as c',
'primaryKey' => 's.channel_id',
'condition' => '=',
'secondaryKey' => 'c.id',
]
],
//use aliasing on secodary columns if join is performed
'columns' => [
[
'name' => 's.id',
'alias' => 'slider_id',
'type' => 'number',
'label' => 'ID',
'sortable' => true,
],
[
'name' => 's.title',
'alias' => 'slider_title',
'type' => 'string',
'label' => 'title',
],
[
'name' => 's.channel_id',
'alias' => 'channel_id',
'type' => 'string',
'label' => 'Channel ID',
'sortable' => true,
],
[
'name' => 'c.name',
'alias' => 'channel_name',
'type' => 'string',
'label' => 'Channel Name',
'sortable' => true,
],
],
//don't use aliasing in case of filters
'filterable' => [
// [
// 'column' => 'id',
// 'alias' => 'locale_id',
// 'type' => 'number',
// 'label' => 'ID',
// ],
// [
// 'column' => 'code',
// 'alias' => 'locale_code',
// 'type' => 'string',
// 'label' => 'Code',
// ],
// [
// 'column' => 'name',
// 'alias' => 'locale_name',
// 'type' => 'string',
// 'label' => 'Name',
// ],
],
//don't use aliasing in case of searchables
'searchable' => [
// [
// 'column' => 'name',
// 'type' => 'string',
// 'label' => 'Name',
// ],
// [
// 'column' => 'code',
// 'type' => 'string',
// 'label' => 'Code',
// ],
],
//list of viable operators that will be used
'operators' => [
'eq' => "=",
'lt' => "<",
'gt' => ">",
'lte' => "<=",
'gte' => ">=",
'neqs' => "<>",
'neqn' => "!=",
'like' => "like",
'nlike' => "not like",
],
// 'css' => []
]);
$view->with('datagrid', $datagrid);
// $view->with('count', $this->users->count());
}
}

View File

@ -26,37 +26,14 @@ class UserComposer
*/
public function compose(View $view)
{
$datagrid = DataGrid::make([
'name' => 'Admins',
'table' => 'admins as u',
'select' => 'u.id',
'aliased' => true, //boolean to validate aliasing on the basis of this.
'filterable' => [
[
'column' => 'u.email',
'type' => 'string',
'label' => 'Admin E-Mail'
], [
'column' => 'u.name',
'type' => 'string',
'label' => 'Admin Name'
], [
'column' => 'u.id',
'type' => 'number',
'label' => 'Admin ID'
]
],
'searchable' => [
[
'column' => 'u.email',
'type' => 'string',
'label' => 'Admin E-Mail'
], [
'column' => 'u.name',
'type' => 'string',
'label' => 'Admin Name'
]
],
'perpage' => 5,
'aliased' => true, //use this with false as default and true in case of joins
'massoperations' =>[
[
'route' => route('admin.datagrid.delete'),
@ -76,40 +53,72 @@ class UserComposer
// ]
// ],
],
'join' => [
// [
// 'join' => 'leftjoin',
// 'table' => 'roles as r',
// 'primaryKey' => 'u.role_id',
// 'condition' => '=',
// 'secondaryKey' => 'r.id',
// ]
'actions' => [
[
'type' => 'Edit',
'route' => route('admin.datagrid.delete'),
'confirm_text' => 'Do you really want to do this?',
'icon' => 'icon pencil-lg-icon',
], [
'type' => 'Delete',
'route' => route('admin.datagrid.delete'),
'confirm_text' => 'Do you really want to do this?',
'icon' => 'icon trash-icon',
],
],
'join' => [
[
'join' => 'leftjoin',
'table' => 'roles as r',
'primaryKey' => 'u.role_id',
'condition' => '=',
'secondaryKey' => 'r.id',
]
],
//use aliasing on secodary columns if join is performed
'columns' => [
[
'name' => 'u.id',
'alias' => 'ID',
'type' => 'string',
'label' => 'Admin ID',
'sortable' => true,
'wrapper' => function ($value, $object) {
return '<a class="color-red">' . $object->ID . '</a>';
},
],
[
'name' => 'u.name',
'alias' => 'Name',
'type' => 'string',
'label' => 'Admin Name',
'label' => 'Name',
'sortable' => true,
'wrapper' => function ($value, $object) {
return '<a class="color-red">' . $object->Name . '</a>';
},
],
[
'name' => 'u.email',
'alias' => 'Email',
'type' => 'string',
'label' => 'Admin E-Mail',
'label' => 'E-Mail',
'sortable' => true,
],
[
'name' => 'r.name',
'alias' => 'xa',
'type' => 'string',
'label' => 'Role Name',
'sortable' => true,
],
[
'name' => 'r.id',
'alias' => 'xc',
'type' => 'string',
'label' => 'Role ID',
'sortable' => true,
],
// [
// 'name' => 'r.name as rolename',
// 'type' => 'string',
// 'label' => 'Role Name',
// 'sortable' => true,
// ],
// [
// 'name' => 'a.first_name',
// 'type' => 'string',
@ -132,6 +141,37 @@ class UserComposer
// ],
],
//don't use aliasing in case of filters
'filterable' => [
[
'column' => 'u.name',
'alias' => 'Name',
'type' => 'string',
'label' => 'Name'
], [
'column' => 'u.id',
'alias' => 'ID',
'type' => 'number',
'label' => 'Admin ID'
], [
'column' => 'r.id',
'alias' => 'Role_ID',
'type' => 'number',
'label' => 'Role ID'
]
],
//don't use aliasing in case of searchables
'searchable' => [
[
'column' => 'u.email',
'type' => 'string',
'label' => 'E-Mail'
], [
'column' => 'u.name',
'type' => 'string',
'label' => 'Name'
]
],
'operators' => [
'eq' => "=",
'lt' => "<",
@ -150,4 +190,4 @@ class UserComposer
$view->with('datagrid', $datagrid);
// $view->with('count', $this->users->count());
}
}
}

View File

@ -212,7 +212,7 @@ Route::group(['middleware' => ['web']], function () {
])->name('admin.countries.store');
// Country Routes
// Currency Routes
Route::get('/currencies', 'Webkul\Core\Http\Controllers\CurrencyController@index')->defaults('_config', [
'view' => 'admin::settings.currencies.index'
])->name('admin.currencies.index');
@ -226,7 +226,7 @@ Route::group(['middleware' => ['web']], function () {
])->name('admin.currencies.store');
// Country Routes
// Exchange Rates Routes
Route::get('/exchange_rates', 'Webkul\Core\Http\Controllers\ExchangeRateController@index')->defaults('_config', [
'view' => 'admin::settings.exchange_rates.index'
])->name('admin.exchange_rates.index');
@ -299,6 +299,20 @@ Route::group(['middleware' => ['web']], function () {
])->name('admin.account.edit');
Route::put('/account', 'Webkul\User\Http\Controllers\AccountController@update')->name('admin.account.update');
// Admin Store Front Settings Route
Route::get('/slider','Webkul\Shop\Http\Controllers\SliderController@index')->defaults('_config',[
'view' => 'admin::settings.sliders.index'
])->name('admin.sliders.index');
// Admin Store Front Settings Route
Route::get('/slider/create','Webkul\Shop\Http\Controllers\SliderController@create')->defaults('_config',[
'view' => 'admin::settings.sliders.create'
])->name('admin.sliders.create');
Route::post('/slider/create','Webkul\Shop\Http\Controllers\SliderController@store')->defaults('_config',[
'redirect' => 'admin::sliders.index'
])->name('admin.sliders.store');
});
});
});

View File

@ -16,14 +16,34 @@ class ComposerServiceProvider extends ServiceProvider
*/
public function boot()
{
// Using class based composers...
//for the users in the countries dashboard
View::composer('admin::settings.countries.index', 'Webkul\Admin\Http\ViewComposers\DataGrids\CountryComposer');
//for the users in the admin dashboard
View::composer('admin::users.users.index', 'Webkul\Admin\Http\ViewComposers\DataGrids\UserComposer');
// Using Closure based composers...
//for the users in the admin dashboard
View::composer('admin::users.roles.index', 'Webkul\Admin\Http\ViewComposers\DataGrids\RolesComposer');
//for the locales in admin dashboard
View::composer('admin::settings.locales.index', 'Webkul\Admin\Http\ViewComposers\DataGrids\LocalesComposer');
//for the currencies in admin dashboard
View::composer('admin::settings.currencies.index', 'Webkul\Admin\Http\ViewComposers\DataGrids\CurrenciesComposer');
//for the Exchange Rates in admin dashboard
View::composer('admin::settings.exchange_rates.index', 'Webkul\Admin\Http\ViewComposers\DataGrids\ExchangeRatesComposer');
//for inventory sources in admin dashboard
View::composer('admin::settings.inventory_sources.index', 'Webkul\Admin\Http\ViewComposers\DataGrids\InventorySourcesComposer');
//for channels in admin dashboard
View::composer('admin::settings.channels.index', 'Webkul\Admin\Http\ViewComposers\DataGrids\ChannelsComposer');
//for sliders in admin dashboard
View::composer('admin::settings.sliders.index', 'Webkul\Admin\Http\ViewComposers\DataGrids\SliderComposer');
// View::composer('admin::users.index', function ($view) {
// //
// });
}
/**

View File

@ -33,13 +33,13 @@ class EventServiceProvider extends ServiceProvider
*/
public function createAdminMenu()
{
Event::listen('admin.menu.create', function() {
return Menu::create(function($menu) {
Event::listen('admin.menu.create', function () {
return Menu::create(function ($menu) {
Event::fire('admin.menu.build', $menu);
});
});
Event::listen('admin.menu.build', function($menu) {
Event::listen('admin.menu.build', function ($menu) {
$menu->add('dashboard', 'Dashboard', 'admin.dashboard.index', 1, 'dashboard-icon');
$menu->add('catalog', 'Catalog', 'admin.catalog.products.index', 3, 'catalog-icon');
@ -75,6 +75,8 @@ class EventServiceProvider extends ServiceProvider
$menu->add('settings.users.users', 'Users', 'admin.users.index', 1, '');
$menu->add('settings.users.roles', 'Roles', 'admin.roles.index', 2, '');
$menu->add('settings.sliders', 'Create Sliders', 'admin.sliders.index', 8, '');
});
}
@ -85,7 +87,7 @@ class EventServiceProvider extends ServiceProvider
*/
public function buildACL()
{
Event::listen('admin.acl.build', function($acl) {
Event::listen('admin.acl.build', function ($acl) {
$acl->add('dashboard', 'Dashboard', 'admin.dashboard.index', 1);
$acl->add('configuration', 'Configure', 'admin.account.edit', 5);
@ -107,7 +109,7 @@ class EventServiceProvider extends ServiceProvider
*/
public function registerACL()
{
$this->app->singleton('acl', function() {
$this->app->singleton('acl', function () {
return current(Event::fire('admin.acl.create'));
});
@ -121,22 +123,14 @@ class EventServiceProvider extends ServiceProvider
*/
public function createProductFormAccordian()
{
Event::listen('admin.catalog.products.accordian.create', function() {
return ProductFormAccordian::create(function($accordian) {
Event::fire('admin.catalog.products.accordian.build', $accordian);
});
});
Event::listen('admin.catalog.products.accordian.build', function($accordian) {
$accordian->add('images', 'Inventories', 'admin::catalog.products.accordians.inventories', 1);
$accordian->add('inventories', 'Inventories', 'admin::catalog.products.accordians.inventories', 1);
$accordian->add('images', 'Images', 'admin::catalog.products.accordians.images', 2);
$accordian->add('categories', 'Categories', 'admin::catalog.products.accordians.categories', 3);
$accordian->add('variations', 'Variations', 'admin::catalog.products.accordians.variations', 4);
// $accordian->add('product-links', 'Linked Products', 'admin::catalog.products.accordians.product-links', 4);
});
}
}

View File

@ -28,6 +28,7 @@ return [
'submit-btn-title' => 'Reset Password'
],
'roles' => [
'title' => 'Roles',
'add-role-title' => 'Add Role',
'edit-role-title' => 'Edit Role',
'save-btn-title' => 'Save Role',
@ -175,6 +176,7 @@ return [
],
'settings' => [
'locales' => [
'title' => 'Locales',
'add-locale-title' => 'Add Locale',
'edit-locale-title' => 'Edit Locale',
'add-title' => 'Add Locale',
@ -184,6 +186,7 @@ return [
'name' => 'Name'
],
'countries' => [
'title' => 'Countries',
'add-title' => 'Add Counrty',
'save-btn-title' => 'Save Counrty',
'general' => 'General',
@ -191,6 +194,7 @@ return [
'name' => 'Name'
],
'currencies' => [
'title' => 'Currencies',
'add-title' => 'Add Currency',
'edit-title' => 'Edit Currency',
'save-btn-title' => 'Save Currency',
@ -249,6 +253,16 @@ return [
'default-locale' => 'Default Locale',
'currencies' => 'Currencies',
'base-currency' => 'Base Currency'
]
],
'sliders' => [
'title' => 'Sliders',
'add-title' => 'Create Slider',
'save-btn-title' => 'Save Slider',
'general' => 'General',
'image' => 'Image',
'content' => 'Content',
'channels' => 'Channel'
],
]
];

View File

@ -4,7 +4,7 @@
<div class="content">
<div class="page-header">
<div class="page-title">
<h1>{{ __('admin::app.settings.channels.title') }}</h1>
</div>
<div class="page-action">
@ -15,7 +15,7 @@
</div>
<div class="page-content">
{!! $datagrid->render() !!}
</div>
</div>
@stop

View File

@ -4,7 +4,7 @@
<div class="content">
<div class="page-header">
<div class="page-title">
<h1>{{ __('admin::app.settings.countries.title') }}</h1>
</div>
<div class="page-action">
@ -15,7 +15,7 @@
</div>
<div class="page-content">
{!! $datagrid->render() !!}
</div>
</div>
@stop

View File

@ -4,7 +4,7 @@
<div class="content">
<div class="page-header">
<div class="page-title">
<h1>{{ __('admin::app.settings.currencies.title') }}</h1>
</div>
<div class="page-action">
@ -15,7 +15,7 @@
</div>
<div class="page-content">
{!! $datagrid->render() !!}
</div>
</div>
@stop

View File

@ -8,7 +8,7 @@
<div class="content">
<div class="page-header">
<div class="page-title">
<h1>{{ __('admin::app.settings.exchange_rates.title') }}</h1>
</div>
<div class="page-action">
@ -19,7 +19,7 @@
</div>
<div class="page-content">
{!! $datagrid->render() !!}
</div>
</div>
@stop

View File

@ -8,7 +8,7 @@
<div class="content">
<div class="page-header">
<div class="page-title">
<h1>{{ __('admin::app.settings.inventory_sources.title') }}</h1>
</div>
<div class="page-action">
@ -19,7 +19,7 @@
</div>
<div class="page-content">
{!! $datagrid->render() !!}
</div>
</div>
@stop

View File

@ -4,7 +4,7 @@
<div class="content">
<div class="page-header">
<div class="page-title">
<h1>{{ __('admin::app.settings.locales.title') }}</h1>
</div>
<div class="page-action">
@ -15,7 +15,7 @@
</div>
<div class="page-content">
{!! $datagrid->render() !!}
</div>
</div>
@stop

View File

@ -0,0 +1,71 @@
@extends('admin::layouts.content')
@section('page_title')
{{ __('admin::app.settings.sliders.add-title') }}
@stop
@section('content')
<div class="content">
<form method="POST" action="{{ route('admin.sliders.create') }}" @submit.prevent="onSubmit" enctype="multipart/form-data">
<div class="page-header">
<div class="page-title">
<h1>{{ __('admin::app.settings.sliders.add-title') }}</h1>
</div>
<div class="page-action">
<button type="submit" class="btn btn-lg btn-primary">
{{ __('admin::app.settings.sliders.save-btn-title') }}
</button>
</div>
</div>
<div class="page-content">
<div class="form-container">
@csrf()
<accordian :title="'{{ __('admin::app.settings.sliders.general') }}'" :active="true">
<div slot="body">
<div class="control-group" :class="[errors.has('title') ? 'has-error' : '']">
<label for="title">{{ __('admin::app.settings.sliders.title') }}</label>
<input type="text" class="control" name="title" v-validate="'required'">
<span class="control-error" v-if="errors.has('title')">@{{ errors.first('title') }}</span>
</div>
<div class="control-group" :class="[errors.has('channel_id') ? 'has-error' : '']">
<label for="channel_id">{{ __('admin::app.settings.sliders.channels') }}</label>
<select class="control" id="channel_id" name="channel_id" value="" v-validate="'required'">
@foreach($channels[0] as $channel)
<option value="{{ $channel->id }}">{{ __($channel->name) }}</option>
@endforeach
</select>
<span class="control-error" v-if="errors.has('channel_id')">@{{ errors.first('channel_id') }}</span>
</div>
<div class="control-group" :class="[errors.has('image') ? 'has-error' : '']">
<label for="new_image">{{ __('admin::app.settings.sliders.image') }}</label>
<image-upload>
<input type="file" class="control" id="add_image" name="image" value="" v-validate="'image|required'" placeholder="Upload from Outer"/>
<span class="control-error" v-if="errors.has('image')">@{{ errors.first('image') }}</span>
{{-- The image field validation is not working, resolve it. --}}
</image-upload>
</div>
<div class="control-group" :class="[errors.has('content') ? 'has-error' : '']">
<label for="content">{{ __('admin::app.settings.sliders.content') }}</label>
<textarea class="control" id="add_content" name="content" v-validate="'required'" rows="5"></textarea>
<span class="control-error" v-if="errors.has('content')">@{{ errors.first('content') }}</span>
</div>
</div>
</accordian>
</div>
</div>
</form>
</div>
@endsection

View File

@ -0,0 +1,21 @@
@extends('admin::layouts.content')
@section('content')
<div class="content">
<div class="page-header">
<div class="page-title">
<h1>{{ __('admin::app.settings.sliders.title') }}</h1>
</div>
<div class="page-action">
<a href="{{ route('admin.sliders.store') }}" class="btn btn-lg btn-primary">
{{ __('admin::app.settings.sliders.add-title') }}
</a>
</div>
</div>
<div class="page-content">
{!! $datagrid->render() !!}
</div>
</div>
@stop

View File

@ -4,7 +4,7 @@
<div class="content">
<div class="page-header">
<div class="page-title">
<h1>{{ __('admin::app.users.roles.title') }}</h1>
</div>
<div class="page-action">
@ -15,7 +15,7 @@
</div>
<div class="page-content">
{!! $datagrid->render() !!}
</div>
</div>
@stop

View File

@ -9,7 +9,7 @@
<div class="content">
<div class="page-header">
<div class="page-title">
<h1>{{ __('admin::app.users.users.title') }}</h1>
</div>
<div class="page-action">
<a href="{{ route('admin.users.create') }}" class="btn btn-lg btn-primary">

View File

@ -19,6 +19,12 @@ class Channel
return $channel->code;
}
public function getCurrentChannel() {
//just retrieve only three columns id, name and code
$current_channel = collect(ChannelModel::select('id', 'name', 'code')->first());
return $current_channel;
}
public function getChannelModel() {
return ChannelModel::first();
}

View File

@ -0,0 +1,39 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateSlidersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('sliders', function (Blueprint $table) {
$table->increments('id');
$table->string('title');
$table->string('path');
$table->string('content');
$table->integer('channel_id')->unsigned();
$table->foreign('channel_id')->references('id')->on('channels')->onDelete('cascade');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::disableForeignKeyConstraints();
Schema::dropIfExists('sliders');
Schema::enableForeignKeyConstraints();
}
}

View File

@ -1,4 +1,4 @@
<?php
<?php
namespace Webkul\Core\Eloquent;
@ -52,7 +52,7 @@ abstract class Repository implements RepositoryInterface {
{
return $this->resetScope()->model->with($with)->get($columns);
}
/**
* @param int $perPage
* @param array $columns
@ -158,7 +158,7 @@ abstract class Repository implements RepositoryInterface {
return $this->model = $model->newQuery();
}
/**
* @return $this
*/

View File

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

View File

@ -45,7 +45,7 @@ class CoreServiceProvider extends ServiceProvider
{
$this->registerCoreFacade();
}
/**
* Register Bouncer as a singleton.
*

View File

@ -0,0 +1,42 @@
<?php
namespace Webkul\Core\Repositories;
use Webkul\Core\Eloquent\Repository;
/**
* Slider Reposotory
*
* @author Prashant Singh <prashant.singh852@webkul.com>
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/
class SliderRepository extends Repository
{
/**
* Specify Model class name
*
* @return mixed
*/
function model()
{
return 'Webkul\Core\Models\Slider';
}
/**
* @param array $data
* @return mixed
*/
public function create(array $data)
{
$image = request()->hasFile('image');
$image_name = uniqid(20).'.'.$image->getClientOriginalExtension();
$destinationPath = public_path('/vendor/webkul/shop/assets/images/slider');
$path = $image->move($destinationPath, $image_name);
$path= 'vendor/webkul/shop/assets/images/slider/'.$image_name;
$data['path'] = $path;
$this->model->create($data);
}
}

View File

@ -5,7 +5,7 @@ Route::group(['middleware' => ['web']], function () {
// Login Routes
Route::get('login', 'Webkul\Customer\Http\Controllers\SessionController@show')->defaults('_config', [
'view' => 'shop::customers.login.index',
'view' => 'shop::customers.session.index',
])->name('customer.session.index');
Route::post('login', 'Webkul\Customer\Http\Controllers\SessionController@create')->defaults('_config', [

View File

@ -5,7 +5,8 @@ namespace Webkul\Shop\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Routing\Controller;
use Webkul\Core\Repositories\SliderRepository as Sliders;
use Webkul\Channel\Channel as Channel;
/**
* Admin user session controller
*
@ -15,13 +16,22 @@ use Illuminate\Routing\Controller;
class HomeController extends controller
{
protected $_config;
protected $sliders;
protected $current_channel;
public function __construct()
public function __construct(Sliders $s,Channel $c)
{
$this->_config = request('_config');
$this->sliders = $s;
$this->current_channel = $c;
}
public function index(){
return view($this->_config['view']);
public function index() {
$current_channel = $this->current_channel->getCurrentChannel();
$all_sliders = $this->sliders->findWhere(['channel_id'=>$current_channel['id']]);
return view($this->_config['view'])->with('data',$all_sliders);
}
}

View File

@ -0,0 +1,61 @@
<?php
namespace Webkul\Shop\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Routing\Controller;
use Webkul\Channel\Channel;
use Webkul\Core\Repositories\SliderRepository as Slider;
/**
* Slider controller
*
* @author Prashant Singh <prashant.singh852@webkul.com>
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/
class SliderController extends controller
{
protected $_config;
protected $slider;
protected $channels;
public function __construct(Slider $slider)
{
$this->slider = $slider;
$this->_config = request('_config');
}
/**
* Loads the index
* for the sliders
* settings.
*/
public function index() {
return view($this->_config['view']);
}
/**
* Loads the form
* for creating
* slider.
*/
public function create() {
$call = new Channel();
$channels = $call->getAllChannels();
return view($this->_config['view'])->with('channels',[$channels]);
}
/**
* Creates the new
* sider item
*/
public function store() {
$this->slider->create(request()->all());
session()->flash('success', 'Slider created successfully.');
return redirect()->back();
}
}

View File

@ -21,6 +21,8 @@ class ShopServiceProvider extends ServiceProvider
{
include __DIR__ . '/../Http/routes.php';
$this->loadTranslationsFrom(__DIR__ . '/../Resources/lang', 'shop');
$this->publishes([
__DIR__ . '/../../publishable/assets' => public_path('vendor/webkul/shop/assets'),
], 'public');

View File

@ -1,13 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="24px" height="24px" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 50 (54983) - http://www.bohemiancoding.com/sketch -->
<!-- Generator: Sketch 50.2 (55047) - http://www.bohemiancoding.com/sketch -->
<title>icon-offer</title>
<desc>Created with Sketch.</desc>
<defs></defs>
<g id="icon-offer" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<polygon id="Star" fill="#FF6472" points="12 21.8341033 8.29179607 23.8299999 6.46471607 20.0352146 2.29179607 19.4698579 3.04372246 15.325663 0 12.415 3.04372246 9.50433697 2.29179607 5.360142 6.46471607 4.79478531 8.29179607 1 12 2.99589665 15.7082039 1 17.5352839 4.79478531 21.7082039 5.360142 20.9562775 9.50433697 24 12.415 20.9562775 15.325663 21.7082039 19.4698579 17.5352839 20.0352146 15.7082039 23.8299999"></polygon>
<text id="%" font-family="Montserrat-Regular, Montserrat" font-size="12" font-weight="normal" letter-spacing="-0.2879999" fill="#FFFFFF">
<tspan x="7.3399999" y="17">%</tspan>
<tspan x="7.8559999" y="17">%</tspan>
</text>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -10,54 +10,18 @@ Vue.component("category-nav", require("./components/category-nav.vue"));
Vue.component("category-item", require("./components/category-item.vue"));
Vue.component("image-slider", require("./components/imageSlider.vue"));
$(window).resize(function() {
var w = $(document).width();
var window = {};
window.width = $(document).width();
window.height = $(document).height();
if (window.width < 785) {
$(".header").css("margin-bottom", "0");
$(".header-top").css("margin-bottom", "0");
$("ul.search-container").css("display", "none");
$(".header-bottom").css("display", "none");
$("div.right-content").css("display", "none");
$(".right-responsive").css("display", "inherit");
} else if (window.width > 785) {
$(".header").css("margin-bottom", "21px");
$(".header-top").css("margin-bottom", "16px");
$("ul.search-container").css("display", "inherit");
$(".header-bottom").css("display", "block");
$("div.right-content").css("display", "inherit");
$(".right-responsive").css("display", "none");
}
});
$(document).ready(function() {
/* Responsiveness script goes here */
var w = $(document).width();
var window = {};
window.width = $(document).width();
window.height = $(document).height();
if (window.width < 785) {
$(".header").css("margin-bottom", "0");
$(".header-top").css("margin-bottom", "0");
$("ul.search-container").css("display", "none");
$(".header-bottom").css("display", "none");
$("div.right-content").css("display", "none");
$(".right-responsive").css("display", "inherit");
}
/* Responsiveness script ends here */
$(document).ready(function () {
const app = new Vue({
el: "#app",
mounted: function() {
mounted: function () {
this.addServerErrors();
this.addFlashMessages();
},
methods: {
onSubmit: function(e) {
onSubmit: function (e) {
this.$validator.validateAll().then(result => {
if (result) {
e.target.submit();
@ -65,7 +29,7 @@ $(document).ready(function() {
});
},
addServerErrors: function() {
addServerErrors: function () {
var scope = null;
for (var key in serverErrors) {
const field = this.$validator.fields.find({
@ -83,14 +47,14 @@ $(document).ready(function() {
}
},
addFlashMessages: function() {
addFlashMessages: function () {
const flashes = this.$refs.flashes;
flashMessages.forEach(function(flash) {
flashMessages.forEach(function (flash) {
flashes.addFlash(flash);
}, this);
},
responsiveHeader: function() {}
responsiveHeader: function () { }
}
});
});

View File

@ -8,7 +8,8 @@
:item="item">
</category-item>
<li>
<img class="icon" src="vendor/webkul/shop/assets/images/offer-zone.svg" style="margin-right:5px;" />Offer Zone
<img src="vendor/webkul/shop/assets/images/offer-zone.svg"/>
<span>Offer Zone</span>
</li>
</ul>

View File

@ -2,7 +2,8 @@
<div class="slider-content">
<ul class="slider-images">
<li>
<img class="slider-item" :src="images[currentIndex]" />
<img class="slider-item" :src="images[currentIndex]" />
<div class="show-content"></div>
</li>
<div class="slider-control">
<span class="icon dark-left-icon slider-left" @click="changeIndexLeft"></span>
@ -13,30 +14,84 @@
</template>
<script>
export default {
props:{
slides: {
type: Array,
required: true,
default: () => [],
}
},
data: function() {
return {
images: [
"vendor/webkul/shop/assets/images/banner.png",
// "vendor/webkul/shop/assets/images/banner.png"
],
currentIndex: 0
currentIndex: 0,
content: [],
};
},
mounted: function() {},
mounted(){
this.getProps();
},
methods: {
getProps() {
this.setProps();
},
setProps() {
for(var i=0;i<this.slides.length;i++) {
this.images.push(this.slides[i].path);
this.content.push(this.slides[i].content);
}
if($('.show-content').html(this.content[0]))
console.log('content pushed');
else
console.log('cannot push');
},
changeIndexLeft: function() {
if (this.currentIndex > 0) {
this.currentIndex--;
if($('.show-content').html(this.content[this.currentIndex]))
console.log('content pushed');
else
console.log('cannot push');
}
else if(this.currentIndex == 0) {
this.currentIndex = this.images.length-1;
if($('.show-content').html(this.content[this.currentIndex]))
console.log('content pushed');
else
console.log('cannot push');
}
},
changeIndexRight: function() {
if (this.currentIndex < 3) {
if(this.currentIndex < this.images.length-1) {
this.currentIndex++;
console.log(this.currentIndex);
} else if (this.currentIndex == 3) {
this.currentIndex = 0;
console.log(this.currentIndex);
if($('.show-content').html(this.content[this.currentIndex]))
console.log('content pushed');
else
console.log('cannot push');
}
else if(this.currentIndex == this.images.length-1) {
this.currentIndex = 0;
if($('.show-content').html(this.content[this.currentIndex]))
console.log('content pushed');
else
console.log('cannot push');
}
}
}
};
</script>
</script>

View File

@ -1,7 +1,6 @@
//shop variables
$font-name: "Montserrat", sans-serif;
$background-color: #f2f2f2;
$fbackground-color: #f2f2f2;
$list-heading-color: rgba(165, 165, 165, 1);
$list-color: #242424;
$subscribe-btn-color: black;
@ -14,7 +13,6 @@ $offer-color: #ff6472;
$sign-up-text-color: #5e5e5e;
$login-text: #3a3a3a;
$background-color: #ffffff;
$border-color: #ffe8e8e8;
$forgot-password-color: #0031f0;
$profile-content-color: #5e5e5e;
//customer variables ends here

View File

@ -194,6 +194,7 @@ body {
// color: $offer-color;
// }
// }
ul.nav {
display: block;
font-size:16px;
@ -240,8 +241,13 @@ body {
}
.nav > li:last-child {
display:flex; align-items:center;
border-radius: 0 0 4px 0;
margin-right: 0;
float:right;
img {
margin-right:6px;
}
}
.nav > li:last-child > a {
@ -309,6 +315,7 @@ body {
ul.slider-images {
li img {
width: 100%;
height: 500px;
object-fit: fill;
}
.slider-control {
@ -456,7 +463,7 @@ body {
}
.footer {
background-color: $fbackground-color;
background-color: $background-color;
padding-left: 10%;
padding-right: 10%;
@ -1423,7 +1430,7 @@ body {
}
}
.footer {
background-color: $fbackground-color;
background-color: $background-color;
padding-left: 4%;
padding-right: 4%;

View File

@ -0,0 +1,34 @@
<?php
return [
'customer' => [
'signup-text' => [
'account_exists' => 'Already have an account',
'title' => 'Sign In'
],
'signup-form' => [
'title' => 'Sign Up',
'firstname' => 'First Name',
'lastname' => 'Last Name',
'email' => 'Email',
'password' => 'Password',
'confirm_pass' => 'Confirm Password',
'button_title' => 'Register',
'agree' => 'Agree',
'terms' => 'Terms',
'conditions' => 'Conditions',
'using' => 'by using this website'
],
'login-text' => [
'no_account' => 'Don\'t have account',
'title' => 'Sign In',
],
'login-form' => [
'title' => 'Sign Up',
'email' => 'E-Mail',
'password' => 'Password',
'forgot_pass' => 'Forgot Password?',
'button_title' => 'Sign In'
]
],
];

View File

@ -1,28 +0,0 @@
@extends('shop::store.layouts.master')
@section('content-wrapper')
<div class="content">
<div class="sign-up-text">
Don't have account - <a href="{{ route('customer.register.index') }}">Sign Up</a>
</div>
<form method="POST" action="{{ route('customer.session.create') }}">
{{ csrf_field() }}
<div class="login-form">
<div class="login-text">Sign In</div>
<div class="control-group">
<label for="email">E-Mail</label>
<input type="text" class="control" name="email">
</div>
<div class="control-group">
<label for="password">Password</label>
<input type="password" class="control" name="password">
</div>
<div class="forgot-password-link">
<a href="">Forgot Password?</a>
</div>
<input class="btn btn-primary btn-lg" type="submit" value="sign in">
</div>
</form>
</div>
@endsection

View File

@ -0,0 +1,41 @@
@extends('shop::store.layouts.master')
@section('content-wrapper')
<div class="content">
<div class="sign-up-text">
{{ __('shop::app.customer.login-text.no_account') }} - <a href="{{ route('customer.register.index') }}">{{ __('shop::app.customer.login-form.title') }}</a>
</div>
<form method="POST" action="{{ route('customer.session.create') }}">
{{ csrf_field() }}
<div class="login-form">
<div class="login-text">{{ __('shop::app.customer.login-text.title') }}</div>
<div class="control-group" :class="[errors.has('email') ? 'has-error' : '']">
<label for="email">{{ __('shop::app.customer.login-form.email') }}</label>
<input type="text" class="control" name="email" v-validate="'required|email'">
<span class="control-error" v-if="errors.has('email')">@{{ errors.first('email') }}</span>
</div>
<div class="control-group" :class="[errors.has('password') ? 'has-error' : '']">
<label for="password">{{ __('shop::app.customer.login-form.password') }}</label>
<input type="password" class="control" name="password" v-validate="'required|min:8|max:100'">
<span class="control-error" v-if="errors.has('password')">@{{ errors.first('password') }}</span>
</div>
<div class="forgot-password-link">
<a href="">{{ __('shop::app.customer.login-form.forgot_pass') }}</a>
</div>
<input class="btn btn-primary btn-lg" type="submit" value="{{ __('shop::app.customer.login-form.button_title') }}">
</div>
</form>
</div>
@endsection

View File

@ -1,55 +1,62 @@
@extends('shop::store.layouts.master')
@section('content-wrapper')
<div class="content">
<div class="sign-up-text">
Already have an account - <a href="{{ route('customer.session.index') }}">Sign In</a>
</div>
<form method="post" action="{{ route('customer.register.create') }}">
{{ csrf_field() }}
<div class="content">
<div class="login-form">
<div class="login-text">Sign Up</div>
<div class="sign-up-text">
{{ __('shop::app.customer.signup-text.account_exists') }} - <a href="{{ route('customer.session.index') }}">{{ __('shop::app.customer.signup-text.title') }}</a>
</div>
<div class="control-group" :class="[errors.has('first_name') ? 'has-error' : '']">
<label for="email">First Name</label>
<input type="text" v-validate="'required'" class="control" name="first_name">
<span class="control-error" v-if="errors.has('first_name')">@{{ errors.first('first_name') }}</span>
</div>
<form method="post" action="{{ route('customer.register.create') }}">
<div class="control-group">
<label for="email">Last Name</label>
<input type="text" class="control" name="last_name">
</div>
{{ csrf_field() }}
<div class="control-group">
<label for="email">Email</label>
<input type="email" class="control" name="email">
</div>
<div class="login-form">
<div class="control-group">
<label for="email">Password</label>
<input type="password" class="control" name="password">
</div>
<div class="login-text">{{ __('shop::app.customer.signup-form.title') }}</div>
<div class="control-group">
<label for="email">Confirm Password</label>
<input type="password" class="control" name="confirm_password">
</div>
<div class="signup-confirm">
<span class="checkbox">
<input type="checkbox" id="checkbox2" name="agreement" required>
<label class="checkbox-view" for="checkbox2"></label>
<span>Agree <a href="">Terms</a> & <a href="">Conditions</a> by using this website.</span>
</span>
</div>
<input class="btn btn-primary btn-lg" type="submit" value="sign in">
<div class="control-group" :class="[errors.has('first_name') ? 'has-error' : '']">
<label for="first_name">{{ __('shop::app.customer.signup-form.firstname') }}</label>
<input type="text" class="control" name="first_name" v-validate="'required'">
<span class="control-error" v-if="errors.has('first_name')">@{{ errors.first('first_name') }}</span>
</div>
</form>
<div class="control-group" :class="[errors.has('last_name') ? 'has-error' : '']">
<label for="last_name">{{ __('shop::app.customer.signup-form.lastname') }}</label>
<input type="text" class="control" name="last_name" v-validate="'required'">
<span class="control-error" v-if="errors.has('last_name')">@{{ errors.first('last_name') }}</span>
</div>
</div>
<div class="control-group" :class="[errors.has('email') ? 'has-error' : '']">
<label for="email">{{ __('shop::app.customer.signup-form.email') }}</label>
<input type="email" class="control" name="email" v-validate="'required|email'">
<span class="control-error" v-if="errors.has('email')">@{{ errors.first('email') }}</span>
</div>
<div class="control-group" :class="[errors.has('password') ? 'has-error' : '']">
<label for="password">{{ __('shop::app.customer.signup-form.password') }}</label>
<input type="password" class="control" name="password" v-validate="'required|min:8'" ref="password">
<span class="control-error" v-if="errors.has('password')">@{{ errors.first('password') }}</span>
</div>
<div class="control-group" :class="[errors.has('confirm_password') ? 'has-error' : '']">
<label for="confirm_password">{{ __('shop::app.customer.signup-form.confirm_pass') }}</label>
<input type="password" class="control" name="confirm_password" v-validate="'required|min:8|confirm:$password'">
<span class="control-error" v-if="errors.has('confirm_password')">@{{ errors.first('confirm_password') }}</span>
</div>
<div class="signup-confirm" :class="[errors.has('agreement') ? 'has-error' : '']">
<span class="checkbox">
<input type="checkbox" id="checkbox2" name="agreement" required>
<label class="checkbox-view" for="checkbox2"></label>
<span>{{ __('shop::app.customer.signup-form.agree') }} <a href="">{{ __('shop::app.customer.signup-form.terms') }}</a> & <a href="">{{ __('shop::app.customer.signup-form.conditions') }}</a> {{ __('shop::app.customer.signup-form.using') }}.</span>
</span>
</div>
<input class="btn btn-primary btn-lg" type="submit" value="{{ __('shop::app.customer.signup-form.button_title') }}">
</div>
</form>
</div>
@endsection

View File

@ -74,4 +74,46 @@
<div class="header-bottom">
@include('shop::store.header.nav-menu.navmenu')
</div>
</div>
</div>
@section('javascript')
<script>
$(window).resize(function() {
var w = $(document).width();
var window = {};
window.width = $(document).width();
window.height = $(document).height();
if (window.width < 785) {
$(".header").css("margin-bottom", "0");
$(".header-top").css("margin-bottom", "0");
$("ul.search-container").css("display", "none");
$(".header-bottom").css("display", "none");
$("div.right-content").css("display", "none");
$(".right-responsive").css("display", "inherit");
} else if (window.width > 785) {
$(".header").css("margin-bottom", "21px");
$(".header-top").css("margin-bottom", "16px");
$("ul.search-container").css("display", "inherit");
$(".header-bottom").css("display", "block");
$("div.right-content").css("display", "inherit");
$(".right-responsive").css("display", "none");
}
});
$(document).ready(function (){
/* Responsiveness script goes here */
var w = $(document).width();
var window = {};
window.width = $(document).width();
window.height = $(document).height();
if (window.width < 785) {
$(".header").css("margin-bottom", "0");
$(".header-top").css("margin-bottom", "0");
$("ul.search-container").css("display", "none");
$(".header-bottom").css("display", "none");
$("div.right-content").css("display", "none");
$(".right-responsive").css("display", "inherit");
}
/* Responsiveness script ends here */
});
</script>
@endsection

View File

@ -1,3 +1,3 @@
<section class="slider-block">
<image-slider></image-slider>
<image-slider :slides='@json($data)'> </image-slider>
</section>

View File

@ -9,7 +9,7 @@ use Illuminate\Support\Facades\DB;
use Webkul\Ui\DataGrid\Helpers\Column;
use Webkul\Ui\DataGrid\Helpers\Pagination;
use Webkul\Ui\DataGrid\Helpers\Css;
use Webkul\Ui\DataGrid\Helpers\MassAction;
use URL;
class DataGrid
{
@ -32,6 +32,13 @@ class DataGrid
*/
protected $aliased;
/**
* Pagination variable
* @var String
*/
protected $perpage;
/**
* Table
*
@ -96,6 +103,13 @@ class DataGrid
*/
protected $css;
/**
* Actions $action
* @var action
*/
protected $actions;
/**
* URL parse $parsed
* @var parse
@ -127,9 +141,9 @@ class DataGrid
// list($name, $select, $table, $join, $columns) = array_values($args);
$name = $select = $aliased = $table = false;
$join = $columns = $filterable = $searchable =
$massoperations = $css = $operators = [];
$massoperations = $css = $operators = $actions = [];
extract($args);
return $this->build($name, $select, $filterable, $searchable, $massoperations, $aliased, $table, $join, $columns, $css, $operators);
return $this->build($name, $select, $filterable, $searchable, $massoperations, $aliased, $perpage, $table, $join, $columns, $css, $operators,$actions);
}
//starts buikding the queries on the basis of selects, joins and filter with
@ -142,11 +156,13 @@ class DataGrid
array $searchable = [],
array $massoperations = [],
bool $aliased = false,
$perpage = 0,
$table = null,
array $join = [],
array $columns = null,
array $css = [],
array $operators = [],
array $actions = [],
Pagination $pagination = null
) {
$this->request = Request::capture();
@ -156,11 +172,13 @@ class DataGrid
$this->setSearchable($filterable);
$this->setMassOperations($massoperations);
$this->setAlias($aliased);
$this->setPerPage($perpage);
$this->setTable($table);
$this->setJoin($join);
$this->addColumns($columns, true);
$this->setCss($css);
$this->setOperators($operators);
$this->setActions($actions);
// $this->addPagination($pagination);
return $this;
}
@ -185,7 +203,7 @@ class DataGrid
public function setSelect($select)
{
$this->select = $select ?: false;
$this->select = $select ? : false;
return $this;
}
@ -196,7 +214,7 @@ class DataGrid
public function setFilterable(array $filterable)
{
$this->filterable = $filterable ?: [];
$this->filterable = $filterable ? : [];
return $this;
}
@ -207,7 +225,7 @@ class DataGrid
public function setSearchable($searchable)
{
$this->searchable = $searchable ?: [];
$this->searchable = $searchable ? : [];
return $this;
}
@ -218,7 +236,7 @@ class DataGrid
public function setMassOperations($massops)
{
$this->massoperations = $massops ?: [];
$this->massoperations = $massops ? : [];
return $this;
}
@ -233,6 +251,21 @@ class DataGrid
public function setAlias(bool $aliased)
{
$this->aliased = $aliased ? : false;
return $this;
}
/**
* Set the default
* pagination for
* data grid.
*
* @return $this
*/
public function setPerPage($perpage)
{
$this->perpage = $perpage ? : 5;
return $this;
}
/**
@ -283,6 +316,17 @@ class DataGrid
// return $this;
// }
/**
* Section actions bag
* here.
* @return $this
*/
public function setActions($actions = []) {
$this->actions = $actions ?: [];
return $this;
}
/**
* Add Columns.
*
@ -385,55 +429,63 @@ class DataGrid
return $this;
}
/**
* Parse the URL
* and get it ready
* to be used.
*/
// private function parse()
// {
// //parse the url here
// if (isset($_SERVER['QUERY_STRING'])) {
// $qr = $_SERVER['QUERY_STRING'];
// parse_str($qr, $parsed);
// foreach ($parsed as $k=>$v) {
// parse_str($v, $parsed[$k]);
// }
// return $parsed;
// } else {
// return $parsed = [];
// }
// }
private function parse()
{
$parsed = [];
$unparsed = $_SERVER['QUERY_STRING'];
if (isset($unparsed)) {
parse_str($unparsed, $parsed);
return $parsed;
} else {
return $parsed;
}
}
/**
* Used for selecting
* the columns got in
* make from controller.
* @return $this
*/
private function getSelect()
{
$select = [];
foreach ($this->columns as $column) {
$select[] = $column->name;
$select[] = $column->name.' as '.$column->alias;
}
$this->query->select(...$select);
if ($this->select) {
$this->query->addselect($this->select);
}
// dd($this->query);
}
/**
* To find the alias
* of the column and
* by taking the column
* name.
* @return string
*/
public function findAlias($column_alias) {
foreach($this->columns as $column) {
if($column->alias == $column_alias) {
return $column->name;
}
}
}
/**
* Parse the URL
* and get it ready
* to be used.
*/
private function parse()
{
$parsed = [];
$unparsed = url()->full();
if (count(explode('?', $unparsed))>1) {
$to_be_parsed = explode('?', $unparsed)[1];
parse_str($to_be_parsed, $parsed);
unset($parsed['page']);
return $parsed;
} else {
return $parsed;
}
}
/**
@ -452,6 +504,7 @@ class DataGrid
{
foreach ($this->columns as $column) {
if ($column->filter) { // if the filter bag in array exists then these will be applied.
dd($column);
if (count($column->filter['condition']) == count($column->filter['condition'], COUNT_RECURSIVE)) {
$this->query->{$column->filter['function']}(...$column->filter['condition']);
} else {
@ -476,88 +529,22 @@ class DataGrid
}
/**
* Used to get the filter
* params from the Url
* and processed manually
* Function runs when
* filters, sort, search
* any of it is applied
* @return $this->query
*/
// private function getQueryWithFilters()
// {
// // the only use case remaining is making and testing the full validation and testing of
// // aliased case with alias used in column names also.
// if ($this->aliased) {
// //n of joins can lead to n number of aliases for columns and neglect the as for columns
// $parsed = $this->parse();
// // dump($parsed);
// foreach ($parsed as $key => $value) {
// foreach ($value as $column => $filter) {
// if (array_keys($filter)[0]=="like") {
// $this->query->where(
// str_replace('_', '.', $column), //replace the logic of making the column name and consider the case for _ in column name already
// $this->operators[array_keys($filter)[0]],
// '%'.array_values($filter)[0].'%'
// );
// } elseif (array_keys($filter)[0]=="sort") {
// $this->query->orderBy(
// str_replace('_', '.', $column), //replace the logic of making the column name and consider the case for _
// array_values($filter)[0]
// );
// } elseif ($column == "search") {
// $this->query->where(function ($query) use ($filter) {
// foreach ($this->searchable as $search) {
// $query->orWhere($search['column'], 'like', '%'.array_values($filter)[0].'%');
// }
// });
// } else {
// $this->query->where(
// str_replace('_', '.', $column),
// $this->operators[array_keys($filter)[0]],
// array_values($filter)[0]
// );
// }
// }
// }
// } else {
// $parsed = $this->parse();
// foreach ($parsed as $key => $value) {
// foreach ($value as $column => $filter) {
// if (array_keys($filter)[0]=="like") {
// $this->query->where(
// $column,
// $this->operators[array_keys($filter)[0]],
// '%'.array_values($filter)[0].'%'
// );
// } elseif ($column == "search") {
// $this->query->where(function ($query) use ($filter) {
// foreach ($this->searchable as $search) {
// $query->orWhere($search['column'], 'like', '%'.array_values($filter)[0].'%');
// }
// });
// } else {
// $this->query->where(
// $column,
// $this->operators[array_keys($filter)[0]],
// array_values($filter)[0]
// );
// }
// }
// }
// }
// }
private function getQueryWithFilters()
{
$parsed = $this->parse();
if ($this->aliased) {
if ($this->aliased) { //aliasing is expected in this case or it will be changed to presence of join bag
foreach ($parsed as $key=>$value) {
if ($key=="sort") {
//resolve the case with the column helper class
if (strpos($key, ' as ') !== false) {
dd('This column cannot be sorted');
} else {
$column_name = str_replace('_', '.', $key);
}
if(substr_count($key,'_') >= 1)
$column_name = $this->findAlias($key);
//case that don't need any resolving
$count_keys = count(array_keys($value));
@ -567,26 +554,19 @@ class DataGrid
array_values($value)[0]
);
} else {
dump('Sort on two columns cannot exist in backend');
throw new \Exception('Multiple Sort keys Found, Please Resolve the URL Manually.');
}
} elseif ($key=="search") {
if (strpos($key, ' as ') !== false) {
dd('This column cannot be searched');
} else {
$column_name = str_replace('_', '.', $key);
}
$count_keys = count(array_keys($value));
if($count_keys==1)
$this->query->where(function ($query) use ($parsed) {
foreach ($this->searchable as $search) {
$query->orWhere($search['column'], 'like', '%'.$parsed['search']['all'].'%');
}
});
} else {
if (strpos($key, ' as ') !== false) {
dd('This column cannot be filtered');
} else {
$column_name = str_replace('_', '.', $key);
}
$column_name = $this->findAlias($key);
if (array_keys($value)[0]=="like" || array_keys($value)[0]=="nlike") {
foreach ($value as $condition => $filter_value) {
$this->query->where(
@ -607,7 +587,58 @@ class DataGrid
}
}
} else {
dd('left to be run plainly');
//this is the case for the non aliasing.
foreach ($parsed as $key=>$value) {
if ($key=="sort") {
//case that don't need any resolving
$count_keys = count(array_keys($value));
if ($count_keys==1) {
$this->query->orderBy(
array_keys($value)[0],
array_values($value)[0]
);
} else {
throw new \Exception('Multiple Sort keys Found, Please Resolve the URL Manually.');
}
} elseif ($key=="search") {
$count_keys = count(array_keys($value));
if($count_keys==1)
$this->query->where(function ($query) use ($parsed) {
foreach ($this->searchable as $search) {
$query->orWhere($search['column'], 'like', '%'.$parsed['search']['all'].'%');
}
});
else
throw new \Exception('Multiple Search keys Found, Please Resolve the URL Manually.');
} else {
// $column_name = $key;
$column_name = $this->findAlias($key);
if (array_keys($value)[0]=="like" || array_keys($value)[0]=="nlike") {
foreach ($value as $condition => $filter_value) {
$this->query->where(
$column_name,
$this->operators[$condition],
'%'.$filter_value.'%'
);
}
} else {
foreach ($value as $condition => $filter_value) {
$this->query->where(
$column_name,
$this->operators[$condition],
$filter_value
);
}
}
}
}
}
}
@ -651,14 +682,13 @@ class DataGrid
foreach ($this->join as $join) {
$name = strtolower($join['join']);
//Allow joins i.e left or right
if ($name=='leftjoin' || $name=='left join' || $name=='rightjoin' || $name=='right join') {
if ($name=='leftjoin' || $name=='rightjoin') {
//check if the aliasing on the primary table and primaryKey in join is also the same
$primary_key_alias = trim(explode('.', $join['primaryKey'])[0]);
if ($primary_key_alias == $table_alias) {
$join_table_alias = explode('as', $join['table']);
if (isset($join_table_alias)) {
$alias1 = trim($join_table_alias[1]); //important!!!!!
@ -668,24 +698,8 @@ class DataGrid
$exploded_secondary = explode('.', $secondary_join_column);
$alias2 = trim($exploded_secondary[0]);
if ($alias1 == $alias2) {
//check whether secondary table columns are properly aliased
$this->getQueryWithJoin();
$alias_proper_secondary = true;
foreach ($this->columns as $column) {
if ($x = explode('.', $column->name)[0]) {
if (isset($x) && $x == $alias1) {
//check if this secondary column is using independent column alias
if (!strpos($column->name, 'as')) {
$alias_proper_secondary = false;
}
}
}
}
if ($alias_proper_secondary) {
$this->getQueryWithJoin();
} else {
throw new \Exception('Due to a bug in laravel, you can\'t use secondary table columns without aliasing');
}
} else {
throw new \Exception('Aliases of Join table and the secondary key columns do not match');
}
@ -706,58 +720,37 @@ class DataGrid
}
//Check for column filter bags and resolve aliasing
//run this if there are columns with filter bag
$this->getQueryWithColumnFilters();
//Run this if there are filters or sort params or range params in the urls
// if (isset($_SERVER['QUERY_STRING'])) {
// $qr = $_SERVER['QUERY_STRING'];
// $parsed;
// parse_str($qr, $parsed);
// }
$parsed = $this->parse();
if (!empty($parsed)) {
$this->getQueryWithFilters();
} else {
$this->results = $this->query->get();
return $this->results;
}
$this->results = $this->query->get();
$this->results = $this->query->paginate($this->perpage)->appends(request()->except('page'));
return $this->results;
} else {
$this->query = DB::table($this->table);
if (!empty($this->select)) {
$this->getSelect();
}
$this->getSelect();
$this->getQueryWithColumnFilters();
$parsed = $this->parse();
if (!empty($parsed)) {
$this->getQueryWithFilters();
} else {
$this->results = $this->query->get();
return $this->results;
}
$this->results = $this->query->get();
$this->results = $this->query->paginate($this->perpage)->appends(request()->except('page'));
return $this->results;
}
}
/**
* Render mass
* action instance
* @return view
*/
// private function renderMassAction(array $attributes)
// {
// //probably render some view when mass action is needed
// //the rendered view will have the needed javascript also.
// }
/**
* @return view
*/
@ -772,6 +765,7 @@ class DataGrid
'filterable' =>$this->filterable,
'operators' => $this->operators,
'massoperations' => $this->massoperations,
'actions' => $this->actions,
]);
}
}
}

View File

@ -11,19 +11,9 @@ class Column extends AbstractFillable
private $request = null;
private $readableName = false;
private $aliasing = false;
private $value = false;
private $sortHtml = '<a href="%s">%s</a>';
// private $sortHtml = '<span href="%s">%s</span>';
// protected $name;
// protected $type;
// protected $label;
// protected $filterable;
// protected $sortable;
// protected $attributes;
// protected $wrapper;
// protected $callback;
/**
* Without Array it will treat it like string
@ -53,7 +43,14 @@ class Column extends AbstractFillable
'type',
'label',
'sortable',
'searchable',
'filterable',
'massoperations' => [
'allowed' => 'array'
],
'actions' => [
'allowed' => 'array'
],
'filter' => [
'allowed' => 'array',
],
@ -120,7 +117,6 @@ class Column extends AbstractFillable
$this->value = call_user_func($this->wrapper, $this->value, $obj);
}
}
private function sortingUrl()
{
$query = ['sort' => $this->correct(false)];
@ -153,10 +149,12 @@ class Column extends AbstractFillable
public function render($obj)
{
if (property_exists($obj, ($this->readableName = $this->correct()))) {
$this->value = $obj->{$this->readableName};
if (property_exists($obj, ($this->aliasing = $this->alias))) {
$this->value = $obj->{$this->aliasing};
$this->wrap($obj);
}
return $this->value;
}
}

View File

@ -0,0 +1,727 @@
<?php
namespace Webkul\Ui\DataGrid;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;
use Illuminate\Support\Validate;
use Illuminate\Pagination\Paginator;
use Illuminate\Support\Facades\DB;
use Webkul\Ui\DataGrid\Helpers\Column;
use Webkul\Ui\DataGrid\Helpers\Pagination;
use Webkul\Ui\DataGrid\Helpers\Css;
use Webkul\Ui\DataGrid\Helpers\MassAction;
use URL;
class ProductGrid
{
/**
* Name of DataGrid
*
* @var string
*/
protected $name;
/**
* select from table(s)
*
* @var string
*/
protected $select;
/**
* Table
* @var Boolean for aliasing
*/
protected $aliased;
/**
* Pagination variable
* @var String
*/
protected $perpage;
/**
* Table
*
* @var String Classs name $table
*/
protected $table;
/**
* Join
*
* @var Array name $join
*
* [
* 'join' => 'left',
* 'table' => 'posts',
* 'primaryKey' => 'user.id',
* 'condition' => '=',
* 'secondryKey' => 'posts.user_id',
* 'callback' => 'not supported yet'
* ]
*/
protected $join;
/**
* Collection Object of Column $columns
*
* @var Collection
*/
protected $columns;
/**
* array of columns
* to be filtered
* @var Array
*/
protected $filterable;
/**
* array of columns
* to be searched
*
* @var Array
*/
protected $searchable;
/**
* mass operations
*
* @var Array
*/
protected $massoperations;
/**
* Pagination $pagination
*
* @var Pagination
*/
protected $pagination;
/**
* Css $css
*
* @var Css
*/
protected $css;
/**
* URL parse $parsed
* @var parse
*/
protected $parsed;
/*
public function __construct(
$name = null ,
$table = null ,
array $join = [],
Collection $columns = null,
Pagination $pagination = null
){
$this->make(
$name,
$table,
$join,
$columns,
$pagination
);
return $this;
Separates the bags in the array of make attributes
}
*/
public function make($args)
{
// list($name, $select, $table, $join, $columns) = array_values($args);
$name = $select = $aliased = $table = false;
$join = $columns = $filterable = $searchable =
$massoperations = $css = $operators = [];
extract($args);
return $this->build($name, $select, $filterable, $searchable, $massoperations, $aliased, $perpage, $table, $join, $columns, $css, $operators);
}
//starts buikding the queries on the basis of selects, joins and filter with
//attributes for class names and styles.
public function build(
$name = null,
$select = false,
array $filterable = [],
array $searchable = [],
array $massoperations = [],
bool $aliased = false,
$perpage = 0,
$table = null,
array $join = [],
array $columns = null,
array $css = [],
array $operators = [],
Pagination $pagination = null
) {
$this->request = Request::capture();
$this->setName($name);
$this->setSelect($select);
$this->setFilterable($filterable);
$this->setSearchable($filterable);
$this->setMassOperations($massoperations);
$this->setAlias($aliased);
$this->setPerPage($perpage);
$this->setTable($table);
$this->setJoin($join);
$this->addColumns($columns, true);
$this->setCss($css);
$this->setOperators($operators);
// $this->addPagination($pagination);
return $this;
}
/**
* Set Name.
*
* @return $this
*/
public function setName(string $name)
{
$this->name = $name ?: 'Default' . time();
return $this;
}
/**
* Set Select.
*
* @return $this
*/
public function setSelect($select)
{
$this->select = $select ? : false;
return $this;
}
/**
* Set Filterable
* @return $this
*/
public function setFilterable(array $filterable)
{
$this->filterable = $filterable ? : [];
return $this;
}
/**
* Set Searchable columns
* @return $this
*/
public function setSearchable($searchable)
{
$this->searchable = $searchable ? : [];
return $this;
}
/**
* Set mass operations
* @return $this
*/
public function setMassOperations($massops)
{
$this->massoperations = $massops ? : [];
return $this;
}
/**
* Set alias parameter
* to know whether
* aliasing is true or not.
*
* @return $this.
*/
public function setAlias(bool $aliased)
{
$this->aliased = $aliased ? : false;
return $this;
}
/**
* Set the default
* pagination for
* data grid.
*
* @return $this
*/
public function setPerPage($perpage)
{
$this->perpage = $perpage ? : 5;
return $this;
}
/**
* Set table name in front
* of query scope.
*
* @return $this
*/
public function setTable(string $table)
{
$this->table = $table ?: false;
return $this;
}
/**
* Set join bag if
* present.
*
* @return $this
*/
public function setJoin(array $join)
{
$this->join = $join ?: [];
return $this;
}
/**
* Adds the custom css rules
* @retun $this
*/
private function setCss($css = [])
{
$this->css = new Css($css);
return $this->css;
}
/**
* setFilterableColumns
* @return $this
*/
// public function setFilterableColumns($filterable_columns = [])
// {
// $this->join = $filterable_columns ?: [];
// return $this;
// }
/**
* Add Columns.
*
* @return $this
*/
public function addColumns($columns = [], $reCreate = false)
{
if ($reCreate) {
$this->columns = new Collection();
}
if ($columns) {
foreach ($columns as $column) {
$this->addColumn($column);
}
}
return $this;
}
/**
* Add Column.
*
* @return $this
*/
public function addColumn($column = [])
{
if ($column instanceof Column) {
$this->columns->push($column);
} elseif (gettype($column) == 'array' && $column) {
$this->columns->push(new Column($column, $this->request));
} else {
throw new \Exception("DataGrid: Add Column argument is not valid!");
}
return $this;
}
/**
* Add ColumnMultiple.
* Currently is not
* of any use.
* @return $this
*/
private function addColumnMultiple($column = [], $multiple = false)
{
if ($column instanceof Column) {
if ($multiple) {
if ($this->columns->offsetExists($column->getName())) {
$this->columns->offsetSet($column->getName(). time(), $column);
} else {
$this->columns->offsetSet($column->getName(), $column);
}
} else {
$this->columns->offsetSet($column->getName(), $column);
}
} elseif (gettype($column) == 'array' && $column) {
$columnObj = new Column($column);
if ($multiple) {
if ($this->columns->offsetExists($columnObj->getName())) {
$this->columns->offsetSet($columnObj->getName(). time(), $columnObj);
} else {
$this->columns->offsetSet($columnObj->getName(), $columnObj);
}
} else {
$this->columns->offsetSet($columnObj->getName(), $columnObj);
}
} else {
throw new \Exception("DataGrid: Add Column argument is not valid!");
}
return $this;
}
/**
* Adds expressional verbs to be used
* @return $this
*/
public function setOperators(array $operators)
{
$this->operators = $operators ?: [];
return $this;
}
/**
* Add Pagination.
*
* @return $this
*/
public function addPagination($pagination = [])
{
if ($pagination instanceof Pagination) {
$this->pagination = $pagination;
} elseif (gettype($pagination) == 'array' && $pagination) {
$this->pagination = new Pagination($pagination);
} else {
throw new \Exception("DataGrid: Pagination argument is not valid!");
}
return $this;
}
/**
* Used for selecting
* the columns got in
* make from controller.
* @return $this
*/
private function getSelect()
{
$select = [];
foreach ($this->columns as $column) {
$select[] = $column->name;
}
$this->query->select(...$select);
if ($this->select) {
$this->query->addselect($this->select);
}
}
/**
* Parse the URL
* and get it ready
* to be used.
*/
private function parse()
{
$parsed = [];
$unparsed = url()->full();
if (count(explode('?', $unparsed))>1) {
$to_be_parsed = explode('?', $unparsed)[1];
parse_str($to_be_parsed, $parsed);
unset($parsed['page']);
return $parsed;
} else {
return $parsed;
}
}
/**
* ->join('contacts', 'users.id', '=', 'contacts.user_id')
* @return $this->query
*/
private function getQueryWithJoin()
{
foreach ($this->join as $join) {
$this->query->{$join['join']}($join['table'], $join['primaryKey'], $join['condition'], $join['secondaryKey']);
}
}
private function getQueryWithColumnFilters()
{
foreach ($this->columns as $column) {
if ($column->filter) { // if the filter bag in array exists then these will be applied.
dd($column);
if (count($column->filter['condition']) == count($column->filter['condition'], COUNT_RECURSIVE)) {
$this->query->{$column->filter['function']}(...$column->filter['condition']);
} else {
if (count($column->filter['condition']) == 3) {
$this->query->{$column->filter['function']}(
extract(
array_combine(
// ['key', 'condition', 'value'],
array_fill( //will work with all kind of where conditions
0,
(count($column->filter['condition']) - 1),
'array_fill_nikhil'.time()
),
$column->filter['condition']
)
)
);
}
}
}
}
}
/**
* Function runs when
* filters, sort, search
* any of it is applied
* @return $this->query
*/
private function getQueryWithFilters()
{
$parsed = $this->parse();
if ($this->aliased) { //aliasing is expected in this case or it will be changed to presence of join bag
foreach ($parsed as $key=>$value) {
if ($key=="sort") {
//resolve the case with the column helper class
if(substr_count($key,'_') >= 1)
$column_name = str_replace_first('_', '.', $key);
//case that don't need any resolving
$count_keys = count(array_keys($value));
if ($count_keys==1) {
$this->query->orderBy(
str_replace('_', '.', array_keys($value)[0]),
array_values($value)[0]
);
} else {
throw new \Exception('Multiple Sort keys Found, Please Resolve the URL Manually.');
}
} elseif ($key=="search") {
$count_keys = count(array_keys($value));
if($count_keys==1)
$this->query->where(function ($query) use ($parsed) {
foreach ($this->searchable as $search) {
$query->orWhere($search['column'], 'like', '%'.$parsed['search']['all'].'%');
}
});
} else {
$column_name = str_replace_first('_', '.', $key);
if (array_keys($value)[0]=="like" || array_keys($value)[0]=="nlike") {
foreach ($value as $condition => $filter_value) {
$this->query->where(
$column_name,
$this->operators[$condition],
'%'.$filter_value.'%'
);
}
} else {
foreach ($value as $condition => $filter_value) {
$this->query->where(
$column_name,
$this->operators[$condition],
$filter_value
);
}
}
}
}
} else {
//this is the case for the non aliasing.
foreach ($parsed as $key=>$value) {
if ($key=="sort") {
//case that don't need any resolving
$count_keys = count(array_keys($value));
if ($count_keys==1) {
$this->query->orderBy(
array_keys($value)[0],
array_values($value)[0]
);
} else {
throw new \Exception('Multiple Sort keys Found, Please Resolve the URL Manually.');
}
} elseif ($key=="search") {
$count_keys = count(array_keys($value));
if($count_keys==1)
$this->query->where(function ($query) use ($parsed) {
foreach ($this->searchable as $search) {
$query->orWhere($search['column'], 'like', '%'.$parsed['search']['all'].'%');
}
});
else
throw new \Exception('Multiple Search keys Found, Please Resolve the URL Manually.');
} else {
$column_name = $key;
if (array_keys($value)[0]=="like" || array_keys($value)[0]=="nlike") {
foreach ($value as $condition => $filter_value) {
$this->query->where(
$column_name,
$this->operators[$condition],
'%'.$filter_value.'%'
);
}
} else {
foreach ($value as $condition => $filter_value) {
$this->query->where(
$column_name,
$this->operators[$condition],
$filter_value
);
}
}
}
}
}
}
private function getDbQueryResults()
{
$parsed = $this->parse();
if ($this->aliased==true) {
//flags
$table_alias = false;
$join_table_alias = false;
$allowed_joins = false;
$other_joins = false;
$join_good = false;
//prepare query object
$this->query = DB::table($this->table);
//explode if alias is available
if (strpos('.', $this->table)) {
throw new \Exception("dot/s cannot be used in table names in mysql");
} else {
$exploded = explode('as', $this->table);
}
//check whether exploded string still has same table name
if ($exploded[0]==$this->table) {
$table_alias = false;
} else { // (isset($exploded))
$table_alias = true;
$table_name = trim($exploded[0]);
$table_alias = trim($exploded[1]);
}
//Run this if there are any selects priorly.
if (!empty($this->select)) {
$this->getSelect();
}
//Run this if there are joins
if (!empty($this->join)) {
foreach ($this->join as $join) {
$name = strtolower($join['join']);
//Allow joins i.e left or right
if ($name=='leftjoin' || $name=='rightjoin') {
//check if the aliasing on the primary table and primaryKey in join is also the same
$primary_key_alias = trim(explode('.', $join['primaryKey'])[0]);
if ($primary_key_alias == $table_alias) {
$join_table_alias = explode('as', $join['table']);
if (isset($join_table_alias)) {
$alias1 = trim($join_table_alias[1]); //important!!!!!
//check if the secondary table match column is not having '.' and has proper alias
$secondary_join_column = $join['secondaryKey'];
if (isset($secondary_join_column)) {
$exploded_secondary = explode('.', $secondary_join_column);
$alias2 = trim($exploded_secondary[0]);
if ($alias1 == $alias2) {
$this->getQueryWithJoin();
$alias_proper_secondary = true;
} else {
throw new \Exception('Aliases of Join table and the secondary key columns do not match');
}
} else {
throw new \Exception('Improper aliasing on secondary/join column for join');
}
} else {
throw new \Exception('Join/Secondary table alias is not found for join');
}
} else {
throw new \Exception('Primary key and primary table aliases do not match for join');
}
} else {
$other_joins = true;
throw new \Exception('Please check if there is some fault in your aliasing and do not use as in column names or you might have been using a join that is not allowed i.e cross, inner, etc use left and right join only');
}
}
}
//Check for column filter bags and resolve aliasing
$this->getQueryWithColumnFilters();
if (!empty($parsed)) {
$this->getQueryWithFilters();
}
// $this->results = $this->query->get();
// return $this->results;
$this->results = $this->query->get();
$this->results = $this->query->paginate($this->perpage)->appends(request()->except('page'));
return $this->results;
} else {
$this->query = DB::table($this->table);
$this->getSelect();
$this->getQueryWithColumnFilters();
if (!empty($parsed)) {
$this->getQueryWithFilters();
}
$this->results = $this->query->get();
$this->results = $this->query->paginate($this->perpage)->appends(request()->except('page'));
return $this->results;
}
}
/**
* @return view
*/
public function render()
{
$this->getDbQueryResults();
return view('ui::datagrid.index', [
'css' => $this->css,
'results' => $this->results,
'columns' => $this->columns,
'filterable' =>$this->filterable,
'operators' => $this->operators,
'massoperations' => $this->massoperations,
]);
}
}

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="20px" height="20px" viewBox="0 0 20 20" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 50 (54983) - http://www.bohemiancoding.com/sketch -->
<title>Angle-Left</title>
<desc>Created with Sketch.</desc>
<defs></defs>
<g id="Angle-Left" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g transform="translate(9.500000, 10.000000) scale(-1, 1) translate(-9.500000, -10.000000) translate(6.000000, 3.000000)" id="Path-3" stroke="#A2A2A2" stroke-width="3">
<polyline points="0 0 7 7.058476 0.11598308 14"></polyline>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 715 B

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="18px" height="18px" viewBox="0 0 18 18" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 50.2 (55047) - http://www.bohemiancoding.com/sketch -->
<title>Expand-Light-On</title>
<desc>Created with Sketch.</desc>
<defs></defs>
<g id="Expand-Light-On" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g transform="translate(2.000000, 6.000000)" fill="#8E8E8E" id="Path-2">
<polygon points="0 0 13.3424655 0 6.67123275 7.3125"></polygon>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 635 B

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="20px" height="20px" viewBox="0 0 20 20" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 50.2 (55047) - http://www.bohemiancoding.com/sketch -->
<title>Angle-Right</title>
<desc>Created with Sketch.</desc>
<defs></defs>
<g id="Angle-Right" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round">
<polyline id="Path-3" stroke="#A2A2A2" stroke-width="3" points="7 3 14 10.058476 7.11598308 17"></polyline>
</g>
</svg>

After

Width:  |  Height:  |  Size: 620 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 264 B

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="18px" height="18px" viewBox="0 0 18 18" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 50.2 (55047) - http://www.bohemiancoding.com/sketch -->
<title>Icon-Sm-Cross</title>
<desc>Created with Sketch.</desc>
<defs></defs>
<g id="Icon-Sm-Cross" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round">
<g id="Icon-Cross-Sm" transform="translate(6.000000, 6.000000)" stroke="#ffffff" stroke-width="2">
<path d="M0,0 L6,6" id="Path-2"></path>
<path d="M0,0 L6,6" id="Path-2" transform="translate(3.000000, 3.000000) scale(-1, 1) translate(-3.000000, -3.000000) "></path>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 820 B

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="48px" height="48px" viewBox="0 0 48 48" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 50 (54983) - http://www.bohemiancoding.com/sketch -->
<title>arrow-left-dark</title>
<desc>Created with Sketch.</desc>
<defs></defs>
<g id="arrow-left-dark" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="arrow" transform="translate(24.000000, 24.500000) scale(-1, 1) translate(-24.000000, -24.500000) translate(12.000000, 14.000000)" fill="#000000" fill-rule="nonzero">
<path d="M23.249,11.786 L15.433,19.6 C15.0757568,19.9908753 14.5327035,20.1539647 14.0192179,20.0245859 C13.5057324,19.8952072 13.1047928,19.4942676 12.9754141,18.9807821 C12.8460353,18.4672965 13.0091247,17.9242432 13.4,17.567 L18.965,12 L1.5,12 C0.6715729,12 6.32202717e-08,11.3284271 6.32202717e-08,10.5 C6.32202717e-08,9.6715729 0.6715729,9.00000003 1.5,9 L18.965,9 L13.4,3.433 C13.0091247,3.07575678 12.8460353,2.53270346 12.9754141,2.01921793 C13.1047928,1.5057324 13.5057324,1.10479285 14.0192179,0.975414078 C14.5327035,0.846035307 15.0757568,1.00912465 15.433,1.4 L23.249,9.215 C23.9381714,9.93951416 24.0376587,10.793396 23.249,11.786 Z"></path>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="48px" height="48px" viewBox="0 0 48 48" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 50 (54983) - http://www.bohemiancoding.com/sketch -->
<title>arrow-right-light</title>
<desc>Created with Sketch.</desc>
<defs></defs>
<g id="arrow-right-light" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="arrow" transform="translate(12.000000, 14.000000)" fill="#FFFFFF" fill-rule="nonzero">
<path d="M23.249,11.786 L15.433,19.6 C15.0757568,19.9908753 14.5327035,20.1539647 14.0192179,20.0245859 C13.5057324,19.8952072 13.1047928,19.4942676 12.9754141,18.9807821 C12.8460353,18.4672965 13.0091247,17.9242432 13.4,17.567 L18.965,12 L1.5,12 C0.6715729,12 6.32202717e-08,11.3284271 6.32202717e-08,10.5 C6.32202717e-08,9.6715729 0.6715729,9.00000003 1.5,9 L18.965,9 L13.4,3.433 C13.0091247,3.07575678 12.8460353,2.53270346 12.9754141,2.01921793 C13.1047928,1.5057324 13.5057324,1.10479285 14.0192179,0.975414078 C14.5327035,0.846035307 15.0757568,1.00912465 15.433,1.4 L23.249,9.215 C23.9381714,9.93951416 24.0376587,10.793396 23.249,11.786 Z"></path>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 21.0.2, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="41px" height="41px" viewBox="0 0 41 41" style="enable-background:new 0 0 41 41;" xml:space="preserve">
<style type="text/css">
.st0{fill:#FFFFFF;}
.st1{fill:#333333;}
.st2{fill:#B1B1AE;}
</style>
<path class="st0" d="M31,21.5L31,21.5c5.2,0,9.5,4.3,9.5,9.5l0,0c0,5.2-4.3,9.5-9.5,9.5l0,0c-5.2,0-9.5-4.3-9.5-9.5l0,0
C21.5,25.8,25.8,21.5,31,21.5z"/>
<circle class="st1" cx="31" cy="31" r="5"/>
<g id="checkbox">
<path class="st0" d="M3.5,0.5h13c1.7,0,3,1.3,3,3v13c0,1.7-1.3,3-3,3h-13c-1.7,0-3-1.3-3-3v-13C0.5,1.8,1.8,0.5,3.5,0.5z"/>
<path class="st2" d="M16.5,20h-13C1.6,20,0,18.4,0,16.5v-13C0,1.6,1.6,0,3.5,0h13C18.4,0,20,1.6,20,3.5v13C20,18.4,18.4,20,16.5,20
z M3.5,1C2.1,1,1,2.1,1,3.5v13C1,17.9,2.1,19,3.5,19h13c1.4,0,2.5-1.1,2.5-2.5v-13C19,2.1,17.9,1,16.5,1H3.5z"/>
</g>
<path id="checkbox-checked" class="st1" d="M17,41H3c-1.7,0-3-1.3-3-3V24c0-1.7,1.3-3,3-3h14c1.7,0,3,1.3,3,3v14
C20,39.7,18.7,41,17,41z M13.3,26l-5.9,5.7l-1.7-1.6L4,31.7L7.4,35l7.6-7.4L13.3,26z"/>
<g id="checkbox_1_">
<path class="st0" d="M31,0.5L31,0.5c5.2,0,9.5,4.3,9.5,9.5l0,0c0,5.2-4.3,9.5-9.5,9.5l0,0c-5.2,0-9.5-4.3-9.5-9.5l0,0
C21.5,4.8,25.8,0.5,31,0.5z"/>
<path class="st2" d="M31,20c-5.5,0-10-4.5-10-10c0-5.5,4.5-10,10-10c5.5,0,10,4.5,10,10C41,15.5,36.5,20,31,20z M31,1c-5,0-9,4-9,9
c0,5,4,9,9,9c5,0,9-4,9-9C40,5,36,1,31,1z"/>
</g>
<path id="radio-checked" class="st1" d="M31,41c-5.5,0-10-4.5-10-10s4.5-10,10-10s10,4.5,10,10S36.5,41,31,41z M31,22c-5,0-9,4-9,9
s4,9,9,9s9-4,9-9S36,22,31,22z"/>
</svg>

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -1,13 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="24px" height="24px" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 50.2 (55047) - http://www.bohemiancoding.com/sketch -->
<title>icon-offer</title>
<desc>Created with Sketch.</desc>
<defs></defs>
<g id="icon-offer" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<polygon id="Star" fill="#FF6472" points="12 21.8341033 8.29179607 23.8299999 6.46471607 20.0352146 2.29179607 19.4698579 3.04372246 15.325663 0 12.415 3.04372246 9.50433697 2.29179607 5.360142 6.46471607 4.79478531 8.29179607 1 12 2.99589665 15.7082039 1 17.5352839 4.79478531 21.7082039 5.360142 20.9562775 9.50433697 24 12.415 20.9562775 15.325663 21.7082039 19.4698579 17.5352839 20.0352146 15.7082039 23.8299999"></polygon>
<text id="%" font-family="Montserrat-Regular, Montserrat" font-size="12" font-weight="normal" letter-spacing="-0.2879999" fill="#FFFFFF">
<tspan x="7.8559999" y="17">%</tspan>
</text>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 21.0.2, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="41px" height="41px" viewBox="0 0 41 41" style="enable-background:new 0 0 41 41;" xml:space="preserve">
<style type="text/css">
.st0{fill:#FFFFFF;}
.st1{fill:#333333;}
.st2{fill:#B1B1AE;}
</style>
<path class="st0" d="M31,21.5L31,21.5c5.2,0,9.5,4.3,9.5,9.5l0,0c0,5.2-4.3,9.5-9.5,9.5l0,0c-5.2,0-9.5-4.3-9.5-9.5l0,0
C21.5,25.8,25.8,21.5,31,21.5z"/>
<circle class="st1" cx="31" cy="31" r="5"/>
<g id="checkbox">
<path class="st0" d="M3.5,0.5h13c1.7,0,3,1.3,3,3v13c0,1.7-1.3,3-3,3h-13c-1.7,0-3-1.3-3-3v-13C0.5,1.8,1.8,0.5,3.5,0.5z"/>
<path class="st2" d="M16.5,20h-13C1.6,20,0,18.4,0,16.5v-13C0,1.6,1.6,0,3.5,0h13C18.4,0,20,1.6,20,3.5v13C20,18.4,18.4,20,16.5,20
z M3.5,1C2.1,1,1,2.1,1,3.5v13C1,17.9,2.1,19,3.5,19h13c1.4,0,2.5-1.1,2.5-2.5v-13C19,2.1,17.9,1,16.5,1H3.5z"/>
</g>
<path id="checkbox-checked" class="st1" d="M17,41H3c-1.7,0-3-1.3-3-3V24c0-1.7,1.3-3,3-3h14c1.7,0,3,1.3,3,3v14
C20,39.7,18.7,41,17,41z M13.3,26l-5.9,5.7l-1.7-1.6L4,31.7L7.4,35l7.6-7.4L13.3,26z"/>
<g id="checkbox_1_">
<path class="st0" d="M31,0.5L31,0.5c5.2,0,9.5,4.3,9.5,9.5l0,0c0,5.2-4.3,9.5-9.5,9.5l0,0c-5.2,0-9.5-4.3-9.5-9.5l0,0
C21.5,4.8,25.8,0.5,31,0.5z"/>
<path class="st2" d="M31,20c-5.5,0-10-4.5-10-10c0-5.5,4.5-10,10-10c5.5,0,10,4.5,10,10C41,15.5,36.5,20,31,20z M31,1c-5,0-9,4-9,9
c0,5,4,9,9,9c5,0,9-4,9-9C40,5,36,1,31,1z"/>
</g>
<path id="radio-checked" class="st1" d="M31,41c-5.5,0-10-4.5-10-10s4.5-10,10-10s10,4.5,10,10S36.5,41,31,41z M31,22c-5,0-9,4-9,9
s4,9,9,9s9-4,9-9S36,22,31,22z"/>
</svg>

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -6,6 +6,7 @@ Vue.component("tree-item", require("./components/tree-view/tree-item"));
Vue.component("tree-checkbox", require("./components/tree-view/tree-checkbox"));
Vue.component("tree-radio", require("./components/tree-view/tree-radio"));
Vue.component("modal", require("./components/modal"));
Vue.component("image-upload", require("./components/image/image-upload"));
Vue.component("image-wrapper", require("./components/image/image-wrapper"));
Vue.component("image-item", require("./components/image/image-item"));
Vue.directive("slugify", require("./directives/slugify"));

View File

@ -6,7 +6,7 @@
<i class="icon" :class="iconClass"></i>
</slot>
</div>
<div class="accordian-content">
<slot name="body">
</slot>
@ -26,7 +26,8 @@
data: function() {
return {
isActive: false
isActive: false,
imageData: '',
}
},

View File

@ -0,0 +1,73 @@
<template>
<div class="preview-image">
<slot>
</slot>
<div class="preview-wrapper">
<img class="image-preview" :src="sample"/>
</div>
<div class="remove-preview">
<button class="btn btn-md btn-primary" @click.prevent="removePreviewImage">Remove Image</button>
</div>
</div>
</template>
<script>
export default{
data: function() {
return {
sample: "",
image_file: "",
file: null,
newImage:"",
};
},
mounted: function() {
this.sample = "";
var element = this.$el.getElementsByTagName("input")[0];
var this_this = this;
element.onchange = function() {
var fReader = new FileReader();
fReader.readAsDataURL(element.files[0]);
fReader.onload = function(event) {
this.img = document.getElementsByTagName("input")[0];
this.img.src = event.target.result;
this_this.newImage = this.img.src;
this_this.changePreview();
};
}
},
methods: {
removePreviewImage: function() {
this.sample = "";
},
changePreview: function(){
this.sample = this.newImage;
}
},
computed: {
getInputImage() {
console.log(this.imageData);
}
}
}
</script>
<style>
.preview-wrapper{
height:200px;
width:200px;
padding:5px;
}
.image-preview{
height:190px;
width:190px;
}
</style>

View File

@ -222,7 +222,7 @@ h2 {
}
tbody td {
padding: 12px 10px;
padding: 10px;
border-bottom: solid 1px #d3d3d3;
color: $font-color;
vertical-align: top;
@ -236,7 +236,7 @@ h2 {
}
}
}
tbody tr:last-child td {
border-bottom: none;
}
@ -635,8 +635,6 @@ h2 {
}
.grid-container {
margin-top: 30px;
.filter-wrapper {
display: block;
box-sizing: border-box;
@ -685,21 +683,21 @@ h2 {
.dropdown-filters {
display: inline-flex;
.column-filter {
margin-right: 5px;
// .column-filter {
// margin-right: 5px;
.control {
font-family: "montserrat", sans-serif;
padding-left: 5px;
height: 36px;
width: 150px;
border: 2px solid $control-border-color;
border-radius: 3px;
background-color: white;
color: #8e8e8e;
font-size: 14px;
}
}
// .control {
// font-family: "montserrat", sans-serif;
// padding-left: 5px;
// height: 36px;
// width: 150px;
// border: 2px solid $control-border-color;
// border-radius: 3px;
// background-color: white;
// color: #8e8e8e;
// font-size: 14px;
// }
// }
.more-filters {
margin-right: 5px;
@ -854,7 +852,7 @@ h2 {
}
.table {
thead {
.xyz {
.mass-action-wrapper {
display: flex;
flex-direction: row;
justify-content: flex-start;
@ -874,15 +872,21 @@ h2 {
}
}
tr {
th.sort-head {
th.grid_head {
cursor:pointer;
.sort-down-icon {
margin-left: 8px;
margin-left: 5px;
margin-top: -3px;
vertical-align: middle;
cursor: pointer;
}
}
}
}
.pagination {
margin-top:20px;
}
}
}
@ -951,7 +955,6 @@ h2 {
}
}
.label {
background: #E7E7E7;
@include border-radius(2px);
@ -1025,4 +1028,4 @@ h2 {
background-image: none;
}
}
}
}

View File

@ -34,7 +34,7 @@
}
.angle-left-icon {
background-image: url("../images/Angle-Right.svg");
background-image: url("../images/Angle-Left.svg");
width: 17px;
height: 17px;
}

View File

@ -8,14 +8,13 @@
</div>
</div>
<div class="dropdown-filters">
<div class="column-filter">
<div class="dropdown-list bottom-right" style="display: none;">
<div class="column-filter" style="display: none;">
<div class="dropdown-list bottom-right">
<div class="dropdown-container">
<ul>
@foreach($columns as $column)
<li data-name="{{ $column->name }}">
<li data-name="{{ $column->alias }}">
{{ $column->label }}
<span class="checkbox"><input type="checkbox" id="{{ $column->id }}" name="checkbox1[]"> <label for="checkbox1" class="checkbox-view"></label></span>
</li>
@endforeach
</ul>
@ -36,7 +35,7 @@
<select class="filter-column-select">
<option selected disabled>Select Column</option>
@foreach($filterable as $fcol)
<option value="{{ $fcol['column'] }}" data-type="{{ $fcol['type'] }}" data-label="{{ $fcol['label'] }}">{{ $fcol['label'] }}</option>
<option value="{{ $fcol['alias'] }}" data-type="{{ $fcol['type'] }}" data-label="{{ $fcol['label'] }}">{{ $fcol['label'] }}</option>
@endforeach
</select>
</li>
@ -114,4 +113,3 @@
</span> --}}
</div>
</div>

View File

@ -9,6 +9,7 @@
{{-- Section for datagrid javascript --}}
@section('javascript')
<script type="text/javascript">
var columns = @json($columns); //referential
var allFilters1 = [];
var search_value;
var filter_column;
@ -195,16 +196,21 @@
id.splice(index,1);
}
if(id.length>0) {
$('.mass-action').css('display','');
$('.table-grid-header').css('display','none');
// $('.selected-items').html(id.toString());
$('#indexes').val(id);
}else if(id.length == 0) {
$('.mass-action').css('display','none');
$('.table-grid-header').css('display','');
$('#indexes').val('');
if($('#mastercheckbox').prop('checked')) {
$('#mastercheckbox').prop('checked',false);
}
}
});
@ -216,7 +222,6 @@
if(allFilters1.length>0)
{
for(i=0;i<allFilters1.length;i++) {
console.log(allFilters1[i]);
if(i==0){
url = '?' + allFilters1[i].column + '[' + allFilters1[i].cond + ']' + '=' + allFilters1[i].val;
}
@ -239,6 +244,7 @@
moreSplitted = [];
splitted = t.split('&');
for(i=0;i<splitted.length;i++) {
moreSplitted.push(splitted[i].split('='));
}
for(i=0;i<moreSplitted.length;i++) {
@ -248,29 +254,46 @@
obj.column = col;
obj.cond = cond;
obj.val = val;
allFilters1.push(obj);
if(col!=undefined && cond!=undefined && val!=undefined)
allFilters1.push(obj);
obj = {};
}
makeTagsTestPrior();
makeTags();
}
var label; //use the label to prevent the display of column name on the body
function makeTagsTestPrior() {
//use the label to prevent the display of column name on the body
function makeTags() {
var filterRepeat = 0;
if(allFilters1.length!=0)
for(var i = 0;i<allFilters1.length;i++) {
col_label_tag = $('li[data-name="'+allFilters1[i].column+'"]').text();
var filter_card = '<span class="filter-one" id="'+ i +'"><span class="filter-name">'+ col_label_tag +'</span><span class="filter-value"><span class="f-value">'+ allFilters1[i].val +'</span><span class="icon cross-icon remove-filter"></span></span></span>';
$('.filter-row-two').append(filter_card);
if(allFilters1[i].column == "sort") {
col_label_tag = $('li[data-name="'+allFilters1[i].cond+'"]').text();
var filter_card = '<span class="filter-one" id="'+ i +'"><span class="filter-name">'+ col_label_tag +'</span><span class="filter-value"><span class="f-value">'+ allFilters1[i].val +'</span><span class="icon cross-icon remove-filter"></span></span></span>';
$('.filter-row-two').append(filter_card);
} else if(allFilters1[i].column == "search") {
col_label_tag = "Search";
var filter_card = '<span class="filter-one" id="'+ i +'"><span class="filter-name">'+ col_label_tag +'</span><span class="filter-value"><span class="f-value">'+ allFilters1[i].val +'</span><span class="icon cross-icon remove-filter"></span></span></span>';
$('.filter-row-two').append(filter_card);
} else {
col_label_tag = $('li[data-name="'+allFilters1[i].column+'"]').text().trim();
var filter_card = '<span class="filter-one" id="'+ i +'"><span class="filter-name">'+ col_label_tag +'</span><span class="filter-value"><span class="f-value">'+ allFilters1[i].val +'</span><span class="icon cross-icon remove-filter"></span></span></span>';
$('.filter-row-two').append(filter_card);
}
}
}
//obselete or can be used for mediation control if necessary
//This is being used for validation of url params and making array of filters
function formURL(column, condition, response, urlparams,clabel) {
/*validate the conditions here and do the replacements and
push here in the all filters array*/
var obj1 = {};
if(column == "" || condition == "" || response == ""){
if(column == "" || condition == "" || response == "") {
alert("Please mention all the fields for column, condition and match params for proper functioning");
return false;
}
@ -303,7 +326,7 @@
if(allFilters1[j].column == "sort") {
if(allFilters1[j].column==column && allFilters1[j].cond==condition && allFilters1[j].val==response){
if(response=="asc"){
if(response=="asc") {
allFilters1[j].column = column;
allFilters1[j].cond = condition;
allFilters1[j].val = "desc";
@ -367,7 +390,13 @@
makeURL();
}
}
}
function confirm_click(x){
if (confirm(x)) {
} else {
return false;
}
}
</script>
@endsection

View File

@ -4,11 +4,11 @@
<thead>
<tr class="mass-action" style="display: none;">
<tr class="mass-action" style="display: none; height:63px;">
<th colspan="{{ count($columns)+1 }}">
<div class="xyz">
<div class="mass-action-wrapper">
<span class="massaction-remove">
<span class="icon checkbox-dash-icon"></span>
@ -90,12 +90,23 @@
</span>
</th>
@foreach ($columns as $column) @if($column->sortable == "true")
<th class="labelled-col grid_head sort-head" data-column-name="{{ $column->name }}" data-column-label="{{ $column->label }}"
<th class="grid_head"
@if(strpos($column->alias, ' as '))
<?php $exploded_name = explode(' as ',$column->name); ?>
data-column-name="{{ $exploded_name[0] }}"
@else
data-column-name="{{ $column->alias }}"
@endif
data-column-label="{{ $column->label }}"
data-column-sort="asc">{!! $column->sorting() !!}<span class="icon sort-down-icon"></span>
</th>
@else
<th class="labelled-col grid_head" data-column-name="{{ $column->name }}" data-column-label="{{ $column->label }}">{!! $column->sorting() !!}</th>
<th class="grid_head" data-column-name="{{ $column->alias }}" data-column-label="{{ $column->label }}">{!! $column->sorting() !!}</th>
@endif @endforeach
<th>
Actions
</th>
</tr>
</thead>
<tbody class="{{ $css->tbody }}">
@ -110,8 +121,20 @@
@foreach ($columns as $column)
<td class="">{!! $column->render($result) !!}</td>
@endforeach
<td class="action">
@foreach($actions as $action)
<a @if($action['type']=="Edit") href="{{ url()->current().'/edit/'.$result->id }}" @elseif($action['type']=="Delete") href="{{ url()->current().'/delete/'.$result->id }}" @endif class="Action-{{ $action['type'] }}" id="{{ $result->id }}" onclick="return confirm_click('{{ $action['confirm_text'] }}');">
<i class="{{ $action['icon'] }}"></i>
</a>
@endforeach
</td>
</tr>
@endforeach
</tbody>
</table>
<div class="pagination">
{{ $results->links() }}
</div>
</div>

View File

@ -3,11 +3,11 @@
{{-- Previous Page Link --}}
@if($paginator->onFirstPage())
<a class="page-item previous">
<i class="icon angle-right-icon"></i>
<i class="icon angle-left-icon"></i>
</a>
@else
<a data-page="{{ $paginator->previousPageUrl() }}" href="{{ $paginator->previousPageUrl() }}" id="previous" class="page-item previous">
<i class="icon angle-right-icon"></i>
<a data-page="{{ urldecode($paginator->previousPageUrl()) }}" href="{{ urldecode($paginator->previousPageUrl()) }}" id="previous" class="page-item previous">
<i class="icon angle-left-icon"></i>
</a>
@endif
@ -28,7 +28,7 @@
{{ $page }}
</a>
@else
<a class="page-item" href="{{ $url }}">
<a class="page-item as" href="{{ urldecode($url) }}">
{{ $page }}
</a>
@endif
@ -38,12 +38,12 @@
{{-- Next Page Link --}}
@if ($paginator->hasMorePages())
<a href="{{ $paginator->nextPageUrl() }}" data-page="{{ $paginator->nextPageUrl() }}" id="next" class="page-item next">
<i class="icon angle-left-icon"></i>
<a href="{{ urldecode($paginator->nextPageUrl()) }}" data-page="{{ urldecode($paginator->nextPageUrl()) }}" id="next" class="page-item next">
<i class="icon angle-right-icon"></i>
</a>
@else
<a class="page-item next">
<i class="icon angle-left-icon"></i>
<i class="icon angle-right-icon"></i>
</a>
@endif
</div>