From 5f81a797965f9d9ddd5dc905fcec85e2137b3c9f Mon Sep 17 00:00:00 2001 From: prashant-webkul Date: Thu, 29 Nov 2018 18:05:56 +0530 Subject: [PATCH] Subscription newsletter migration restored and subsctiption newsletter datagrid in admin --- .../src/DataGrids/NewsLetterDataGrid.php | 139 ++++++++++++++++++ .../Admin/src/DataGrids/OrderDataGrid.php | 6 + packages/Webkul/Admin/src/Http/routes.php | 29 ++-- .../src/Providers/EventServiceProvider.php | 14 +- .../Admin/src/Resources/lang/en/app.php | 4 + .../settings/subscribers/index.blade.php | 28 ++++ ...6_173504_create_subscribers_list_table.php | 36 +++++ .../Controllers/SubscriptionController.php | 61 ++++++++ .../Shop/src/Resources/assets/sass/app.scss | 2 +- .../views/layouts/header/index.blade.php | 4 +- 10 files changed, 305 insertions(+), 18 deletions(-) create mode 100644 packages/Webkul/Admin/src/DataGrids/NewsLetterDataGrid.php create mode 100644 packages/Webkul/Admin/src/Resources/views/settings/subscribers/index.blade.php create mode 100644 packages/Webkul/Core/src/Database/Migrations/2018_11_16_173504_create_subscribers_list_table.php create mode 100644 packages/Webkul/Core/src/Http/Controllers/SubscriptionController.php diff --git a/packages/Webkul/Admin/src/DataGrids/NewsLetterDataGrid.php b/packages/Webkul/Admin/src/DataGrids/NewsLetterDataGrid.php new file mode 100644 index 000000000..dc94780b2 --- /dev/null +++ b/packages/Webkul/Admin/src/DataGrids/NewsLetterDataGrid.php @@ -0,0 +1,139 @@ + @prashant-webkul + * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) + */ + +class NewsLetterDataGrid +{ + /** + * The Data Grid implementation. + * + * @var newsletterDataGrid + * for orders + */ + public function newsLetterDataGrid() + { + + return DataGrid::make([ + 'name' => 'Subscriberslist', + 'table' => 'subscribers_list as sublist', + 'select' => 'sublist.id', + 'perpage' => 10, + 'aliased' => false, + //True in case of joins else aliasing key required on all cases + + 'massoperations' =>[ + // [ + // 'route' => route('admin.datagrid.delete'), + // 'method' => 'DELETE', + // 'label' => 'Delete', + // 'type' => 'button', + // ], + ], + + 'actions' => [ + [ + 'type' => 'Delete', + 'route' => route('admin.datagrid.delete'), + 'confirm_text' => 'Do you really want to delete this record?', + 'icon' => 'icon trash-icon', + ], + ], + + 'join' => [], + + //use aliasing on secodary columns if join is performed + 'columns' => [ + [ + 'name' => 'sublist.id', + 'alias' => 'subid', + 'type' => 'number', + 'label' => 'ID', + 'sortable' => true + ], [ + 'name' => 'sublist.is_subscribed', + 'alias' => 'issubs', + 'type' => 'string', + 'label' => 'Subscribed', + 'sortable' => true, + 'wrapper' => function ($value) { + if($value == 0) + return "False"; + else + return "True"; + }, + ], [ + 'name' => 'sublist.email', + 'alias' => 'subsemail', + 'type' => 'string', + 'label' => 'Email', + 'sortable' => true + ] + ], + + 'filterable' => [ + [ + 'column' => 'sublist.id', + 'alias' => 'subid', + 'type' => 'number', + 'label' => 'ID', + ], [ + 'column' => 'sublist.is_subscribed', + 'alias' => 'issubs', + 'type' => 'string', + 'label' => 'Subscribed', + ], [ + 'column' => 'sublist.email', + 'alias' => 'subsemail', + 'type' => 'string', + 'label' => 'Email', + ] + ], + //don't use aliasing in case of searchables + + 'searchable' => [ + [ + 'column' => 'sublist.id', + 'type' => 'number', + 'label' => 'ID', + ], [ + 'column' => 'sublist.is_subscribed', + 'type' => 'string', + 'label' => 'Subscribed', + ], [ + 'column' => 'sublist.email', + 'type' => 'string', + 'label' => 'Email', + ] + ], + + //list of viable operators that will be used + 'operators' => [ + 'eq' => "=", + 'lt' => "<", + 'gt' => ">", + 'lte' => "<=", + 'gte' => ">=", + 'neqs' => "<>", + 'neqn' => "!=", + 'like' => "like", + 'nlike' => "not like", + ], + // 'css' => [] + ]); + } + + public function render() + { + return $this->newsLetterDataGrid()->render(); + } +} \ No newline at end of file diff --git a/packages/Webkul/Admin/src/DataGrids/OrderDataGrid.php b/packages/Webkul/Admin/src/DataGrids/OrderDataGrid.php index 155ecdfcf..59674fd0b 100644 --- a/packages/Webkul/Admin/src/DataGrids/OrderDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/OrderDataGrid.php @@ -96,6 +96,12 @@ class OrderDataGrid 'type' => 'string', 'label' => 'Order Date', 'sortable' => true, + ], [ + 'name' => 'or.channel_name', + 'alias' => 'channelname', + 'type' => 'string', + 'label' => 'Channel Name', + 'sortable' => true, ], [ 'name' => 'or.status', 'alias' => 'orstatus', diff --git a/packages/Webkul/Admin/src/Http/routes.php b/packages/Webkul/Admin/src/Http/routes.php index 337d8a8fd..c81ff9dae 100644 --- a/packages/Webkul/Admin/src/Http/routes.php +++ b/packages/Webkul/Admin/src/Http/routes.php @@ -456,22 +456,29 @@ Route::group(['middleware' => ['web']], function () { Route::put('/account', 'Webkul\User\Http\Controllers\AccountController@update')->name('admin.account.update'); //API Authorizations - Route::get('/api/clients', 'Webkul\Admin\Http\Controllers\AuthorizationController@show')->defaults('_config', [ - 'view' => 'admin::apiauth.client' - ])->name('admin.index.oauth.client'); + // Route::get('/api/clients', 'Webkul\Admin\Http\Controllers\AuthorizationController@show')->defaults('_config', [ + // 'view' => 'admin::apiauth.client' + // ])->name('admin.index.oauth.client'); - //view an OAuth API Client - Route::get('/api/clients/view/{id}', 'Webkul\Admin\Http\Controllers\AuthorizationController@view')->defaults('_config', [ - 'view' => 'admin::apiauth.view' - ])->name('admin.view.oauth.client'); + // //view an OAuth API Client + // Route::get('/api/clients/view/{id}', 'Webkul\Admin\Http\Controllers\AuthorizationController@view')->defaults('_config', [ + // 'view' => 'admin::apiauth.view' + // ])->name('admin.view.oauth.client'); - //edit an OAuth API Client - Route::get('/api/clients/delete/{id}', 'Webkul\Admin\Http\Controllers\AuthorizationController@delete')->defaults('_config', [ - 'view' => 'admin::apiauth.edit' - ])->name('admin.delete.oauth.client'); + // //edit an OAuth API Client + // Route::get('/api/clients/delete/{id}', 'Webkul\Admin\Http\Controllers\AuthorizationController@delete')->defaults('_config', [ + // 'view' => 'admin::apiauth.edit' + // ])->name('admin.delete.oauth.client'); // Admin Store Front Settings Route + Route::get('/subscribers','Webkul\Core\Http\Controllers\SubscriptionController@index')->defaults('_config',[ + 'view' => 'admin::settings.subscribers.index' + ])->name('admin.subscribers.index'); + + //destroy a newsletter subscription item + Route::get('subscribers/delete/{id}', 'Webkul\Core\Http\Controllers\SubscriptionController@destroy'); + //slider index Route::get('/slider','Webkul\Shop\Http\Controllers\SliderController@index')->defaults('_config',[ 'view' => 'admin::settings.sliders.index' diff --git a/packages/Webkul/Admin/src/Providers/EventServiceProvider.php b/packages/Webkul/Admin/src/Providers/EventServiceProvider.php index ba6f5da1a..0e2283949 100644 --- a/packages/Webkul/Admin/src/Providers/EventServiceProvider.php +++ b/packages/Webkul/Admin/src/Providers/EventServiceProvider.php @@ -108,7 +108,7 @@ class EventServiceProvider extends ServiceProvider 'route' => 'admin.account.edit', 'sort' => 1, 'icon-class' => '', - ], + ], // [ // 'key' => 'configuration.sales', // 'name' => 'Sales', @@ -121,7 +121,7 @@ class EventServiceProvider extends ServiceProvider // 'route' => 'admin.configuration.sales.general', // 'sort' => 1, // 'icon-class' => '', - // ], + // ], [ 'key' => 'settings', 'name' => 'Settings', @@ -200,6 +200,12 @@ class EventServiceProvider extends ServiceProvider 'route' => 'admin.tax-rates.index', 'sort' => 2, 'icon-class' => '', + ], [ + 'key' => 'settings.subscribers', + 'name' => 'Newsletter Subscription', + 'route' => 'admin.subscribers.index', + 'sort' => 9, + 'icon-class' => '', ], ]; @@ -276,11 +282,11 @@ class EventServiceProvider extends ServiceProvider $acl->add('catalog.attributes', 'Attributes', 'admin.catalog.attributes.index', 3); $acl->add('catalog.families', 'Families', 'admin.catalog.families.index', 4); - + $acl->add('customers', 'Customers', 'admin.customers.index', 4); $acl->add('customers.customers', 'Customers', 'admin.customers.index', 1); - + $acl->add('customers.groups', 'Groups', 'admin.groups.index', 2); $acl->add('customers.reviews', 'Reviews', 'admin.customers.reviews.index', 3); diff --git a/packages/Webkul/Admin/src/Resources/lang/en/app.php b/packages/Webkul/Admin/src/Resources/lang/en/app.php index b7dd75bc2..eaee6edfe 100644 --- a/packages/Webkul/Admin/src/Resources/lang/en/app.php +++ b/packages/Webkul/Admin/src/Resources/lang/en/app.php @@ -499,6 +499,10 @@ return [ 'delete' => 'Tax Rate Deleted Successfully', 'atleast-one' => 'Cannot Delete Last Tax Rate' ], + + 'subscribers' => [ + 'title' => 'Subscribers' + ] ], 'customers' => [ diff --git a/packages/Webkul/Admin/src/Resources/views/settings/subscribers/index.blade.php b/packages/Webkul/Admin/src/Resources/views/settings/subscribers/index.blade.php new file mode 100644 index 000000000..148538b95 --- /dev/null +++ b/packages/Webkul/Admin/src/Resources/views/settings/subscribers/index.blade.php @@ -0,0 +1,28 @@ +@extends('admin::layouts.content') + +@section('page_title') + {{ __('admin::app.settings.subscribers.title') }} +@stop + +@section('content') + + +
+ + +
+ @inject('subscribers','Webkul\Admin\DataGrids\NewsLetterDataGrid') + {!! $subscribers->render() !!} +
+
+@stop \ No newline at end of file diff --git a/packages/Webkul/Core/src/Database/Migrations/2018_11_16_173504_create_subscribers_list_table.php b/packages/Webkul/Core/src/Database/Migrations/2018_11_16_173504_create_subscribers_list_table.php new file mode 100644 index 000000000..b318f0a21 --- /dev/null +++ b/packages/Webkul/Core/src/Database/Migrations/2018_11_16_173504_create_subscribers_list_table.php @@ -0,0 +1,36 @@ +increments('id'); + $table->string('email'); + $table->boolean('is_subscribed')->default(0); + $table->string('token')->nullable(); + $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::dropIfExists('subscribers_list'); + } +} \ No newline at end of file diff --git a/packages/Webkul/Core/src/Http/Controllers/SubscriptionController.php b/packages/Webkul/Core/src/Http/Controllers/SubscriptionController.php new file mode 100644 index 000000000..db29ae70b --- /dev/null +++ b/packages/Webkul/Core/src/Http/Controllers/SubscriptionController.php @@ -0,0 +1,61 @@ + @prashant-webkul + * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) + */ +class SubscriptionController extends Controller +{ + /** + * Contains route related configuration + * + * @var array + */ + protected $_config; + + /** + * Subscription repository instance + * + * @var instanceof SubscribersListRepository + */ + protected $subscribers; + + public function __construct(Subscribers $subscribers) + { + $this->middleware('admin'); + + $this->subscribers = $subscribers; + + $this->_config = request('_config'); + } + + /** + * Display a listing of the resource. + * + * @return \Illuminate\Http\Response + */ + public function index() + { + return view($this->_config['view']); + } + + /** + * Remove the specified resource from storage. + * + * @param int $id + * @return \Illuminate\Http\Response + */ + public function destroy($id) + { + $this->subscribers->delete($id); + + return redirect()->back(); + } +} \ No newline at end of file diff --git a/packages/Webkul/Shop/src/Resources/assets/sass/app.scss b/packages/Webkul/Shop/src/Resources/assets/sass/app.scss index 9d5731662..bd707cfc6 100644 --- a/packages/Webkul/Shop/src/Resources/assets/sass/app.scss +++ b/packages/Webkul/Shop/src/Resources/assets/sass/app.scss @@ -671,12 +671,12 @@ section.slider-block { div.slider-control { display: block; + cursor: pointer; position: absolute; user-select: none; bottom: 2%; right: 2%; - .dark-left-icon { background-color: $background-color; height: 48px; diff --git a/packages/Webkul/Shop/src/Resources/views/layouts/header/index.blade.php b/packages/Webkul/Shop/src/Resources/views/layouts/header/index.blade.php index 859f0a988..54015bd0f 100644 --- a/packages/Webkul/Shop/src/Resources/views/layouts/header/index.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/layouts/header/index.blade.php @@ -76,7 +76,7 @@ @auth('customer')