Refactored the code for datagrid from view composers to selft dependent injection classes and storefront views directory structure is segregated.

This commit is contained in:
prashant-webkul 2018-08-16 11:35:45 +05:30
parent e9d6b93242
commit 21a16b8cf0
41 changed files with 205 additions and 226 deletions

View File

@ -1,13 +1,19 @@
<?php
namespace Webkul\Admin\Http\ViewComposers\DataGrids;
namespace Webkul\Admin\DataGrids;
use Illuminate\View\View;
use Webkul\Ui\DataGrid\Facades\DataGrid;
// use App\Repositories\UserRepository;
class ChannelsComposer
/**
* Channels DataGrid
*
* @author Prashant Singh <prashant.singh852@webkul.com> @prashant-webkul
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/
class ChannelsDataGrid
{
/**
* The Data Grid implementation.
@ -16,17 +22,10 @@ class ChannelsComposer
* for countries
*/
/**
* Bind data to the view.
*
* @param View $view
* @return void
*/
public function compose(View $view)
public function createChannelsDataGrid()
{
$datagrid = DataGrid::make([
return DataGrid::make([
'name' => 'Channels',
'table' => 'channels',
'select' => 'id',
@ -148,7 +147,10 @@ class ChannelsComposer
]);
$view->with('datagrid', $datagrid);
// $view->with('count', $this->users->count());
}
public function render()
{
return $this->createChannelsDataGrid()->render();
}
}

View File

@ -1,13 +1,19 @@
<?php
namespace Webkul\Admin\Http\ViewComposers\DataGrids;
namespace Webkul\Admin\DataGrids;
use Illuminate\View\View;
use Webkul\Ui\DataGrid\Facades\DataGrid;
// use App\Repositories\UserRepository;
class CountryComposer
/**
* Countries DataGrid
*
* @author Prashant Singh <prashant.singh852@webkul.com> @prashant-webkul
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/
class CountryDataGrid
{
/**
* The Data Grid implementation.
@ -16,17 +22,10 @@ class CountryComposer
* for countries
*/
/**
* Bind data to the view.
*
* @param View $view
* @return void
*/
public function compose(View $view)
public function createCountryDataGrid()
{
$datagrid = DataGrid::make([
return DataGrid::make([
'name' => 'Countries',
'table' => 'countries',
'select' => 'id',
@ -161,7 +160,12 @@ class CountryComposer
]);
$view->with('datagrid', $datagrid);
// $view->with('count', $this->users->count());
}
public function render()
{
return $this->createCountryDataGrid()->render();
}
}

View File

@ -1,32 +1,30 @@
<?php
namespace Webkul\Admin\Http\ViewComposers\DataGrids;
namespace Webkul\Admin\DataGrids;
use Illuminate\View\View;
use Webkul\Ui\DataGrid\Facades\DataGrid;
// use App\Repositories\UserRepository;
/**
* Currencies DataGrid
*
* @author Prashant Singh <prashant.singh852@webkul.com> @prashant-webkul
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/
class CurrenciesComposer
class CurrenciesDataGrid
{
/**
* The Data Grid implementation.
*
* @var CountryComposer
* @var CurrenciesDataGrid
* for countries
*/
/**
* Bind data to the view.
*
* @param View $view
* @return void
*/
public function compose(View $view)
public function createCurrencyDataGrid()
{
$datagrid = DataGrid::make([
return DataGrid::make([
'name' => 'Currencies',
'table' => 'currencies',
'select' => 'id',
@ -148,7 +146,10 @@ class CurrenciesComposer
]);
$view->with('datagrid', $datagrid);
// $view->with('count', $this->users->count());
}
public function render()
{
return $this->createCurrencyDataGrid()->render();
}
}

View File

@ -1,32 +1,31 @@
<?php
namespace Webkul\Admin\Http\ViewComposers\DataGrids;
namespace Webkul\Admin\DataGrids;
use Illuminate\View\View;
use Webkul\Ui\DataGrid\Facades\DataGrid;
// use App\Repositories\UserRepository;
/**
* Exchange Rates DataGrid
*
* @author Prashant Singh <prashant.singh852@webkul.com> @prashant-webkul
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/
class ExchangeRatesComposer
class ExchangeRatesDataGrid
{
/**
* The Data Grid implementation.
*
* @var CountryComposer
* for countries
* @var ExchangeRatesDataGrid
* for Exchange Rates
*/
/**
* Bind data to the view.
*
* @param View $view
* @return void
*/
public function compose(View $view)
public function createExchangeRatesDataGrid()
{
$datagrid = DataGrid::make([
return DataGrid::make([
'name' => 'Exchange Rates',
'table' => 'currency_exchange_rates',
'select' => 'id',
@ -156,7 +155,10 @@ class ExchangeRatesComposer
]);
$view->with('datagrid', $datagrid);
// $view->with('count', $this->users->count());
}
public function render()
{
return $this->createExchangeRatesDataGrid()->render();
}
}

View File

@ -1,32 +1,29 @@
<?php
namespace Webkul\Admin\Http\ViewComposers\DataGrids;
namespace Webkul\Admin\DataGrids;
use Illuminate\View\View;
use Webkul\Ui\DataGrid\Facades\DataGrid;
// use App\Repositories\UserRepository;
/**
* Inventory Sources DataGrid
*
* @author Prashant Singh <prashant.singh852@webkul.com> @prashant-webkul
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/
class InventorySourcesComposer
class InventorySourcesDataGrid
{
/**
* The Data Grid implementation.
*
* @var CountryComposer
* for countries
* @var InventorySourcesDataGrid
* for Inventory Sources
*/
/**
* Bind data to the view.
*
* @param View $view
* @return void
*/
public function compose(View $view)
public function createInventorySourcesDataGrid()
{
$datagrid = DataGrid::make([
return DataGrid::make([
'name' => 'Inventory Sources',
'table' => 'inventory_sources',
'select' => 'id',
@ -161,7 +158,10 @@ class InventorySourcesComposer
// 'css' => []
]);
}
$view->with('datagrid', $datagrid);
public function render()
{
return $this->createInventorySourcesDataGrid()->render();
}
}

View File

@ -1,32 +1,30 @@
<?php
namespace Webkul\Admin\Http\ViewComposers\DataGrids;
namespace Webkul\Admin\DataGrids;
use Illuminate\View\View;
use Webkul\Ui\DataGrid\Facades\DataGrid;
// use App\Repositories\UserRepository;
/**
* Locales DataGrid
*
* @author Prashant Singh <prashant.singh852@webkul.com> @prashant-webkul
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/
class LocalesComposer
class LocalesDataGrid
{
/**
* The Data Grid implementation.
*
* @var CountryComposer
* @var CountryDataGrid
* for countries
*/
/**
* Bind data to the view.
*
* @param View $view
* @return void
*/
public function compose(View $view)
public function createCountryDataGrid()
{
$datagrid = DataGrid::make([
return DataGrid::make([
'name' => 'Locales',
'table' => 'locales',
'select' => 'id',
@ -148,7 +146,10 @@ class LocalesComposer
]);
$view->with('datagrid', $datagrid);
// $view->with('count', $this->users->count());
}
public function render()
{
return $this->createCountryDataGrid()->render();
}
}

View File

@ -1,32 +1,31 @@
<?php
namespace Webkul\Admin\Http\ViewComposers\DataGrids;
namespace Webkul\Admin\DataGrids;
use Illuminate\View\View;
use Webkul\Ui\DataGrid\Facades\DataGrid;
// use App\Repositories\UserRepository;
/**
* User Roles DataGrid
*
* @author Prashant Singh <prashant.singh852@webkul.com> @prashant-webkul
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/
class RolesComposer
class RolesDataGrid
{
/**
* The Data Grid implementation.
*
* @var CountryComposer
* for countries
* @var RolesDataGrid
* for Roles
*/
/**
* Bind data to the view.
*
* @param View $view
* @return void
*/
public function compose(View $view)
public function createRolesDataGrid()
{
$datagrid = DataGrid::make([
return DataGrid::make([
'name' => 'Roles',
'table' => 'roles',
'select' => 'id',
@ -148,7 +147,10 @@ class RolesComposer
]);
$view->with('datagrid', $datagrid);
// $view->with('count', $this->users->count());
}
public function render()
{
return $this->createRolesDataGrid()->render();
}
}

View File

@ -1,32 +1,30 @@
<?php
namespace Webkul\Admin\Http\ViewComposers\DataGrids;
namespace Webkul\Admin\DataGrids;
use Illuminate\View\View;
use Webkul\Ui\DataGrid\Facades\DataGrid;
// use App\Repositories\UserRepository;
/**
* Sliders DataGrid
*
* @author Prashant Singh <prashant.singh852@webkul.com> @prashant-webkul
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/
class SliderComposer
class SliderDataGrid
{
/**
* The Data Grid implementation.
*
* @var CountryComposer
* for countries
* @var SliderDataGrid
* for Sliders
*/
/**
* Bind data to the view.
*
* @param View $view
* @return void
*/
public function compose(View $view)
public function createSliderDataGrid()
{
$datagrid = DataGrid::make([
return DataGrid::make([
'name' => 'Sliders',
'table' => 'sliders as s',
'select' => 's.id',
@ -153,7 +151,10 @@ class SliderComposer
]);
$view->with('datagrid', $datagrid);
// $view->with('count', $this->users->count());
}
public function render()
{
return $this->createSliderDataGrid()->render();
}
}

View File

@ -1,33 +1,30 @@
<?php
namespace Webkul\Admin\Http\ViewComposers\DataGrids;
namespace Webkul\Admin\DataGrids;
use Illuminate\View\View;
use Webkul\Ui\DataGrid\Facades\DataGrid;
// use App\Repositories\UserRepository;
/**
* Users DataGrid
*
* @author Prashant Singh <prashant.singh852@webkul.com> @prashant-webkul
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/
class UserComposer
class UserDataGrid
{
/**
* The Data Grid implementation.
*
* @var UserComposer
* for admin
* @var UserDataGrid
* for admin users
*/
protected $users;
/**
* Bind data to the view.
*
* @param View $view
* @return void
*/
public function compose(View $view)
public function createUserDataGrid()
{
$datagrid = DataGrid::make([
return DataGrid::make([
'name' => 'Admins',
'table' => 'admins as u',
'select' => 'u.id',
@ -59,7 +56,8 @@ class UserComposer
'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?',
@ -148,12 +146,14 @@ class UserComposer
'alias' => 'Name',
'type' => 'string',
'label' => 'Name'
], [
],
[
'column' => 'u.id',
'alias' => 'ID',
'type' => 'number',
'label' => 'Admin ID'
], [
],
[
'column' => 'r.id',
'alias' => 'Role_ID',
'type' => 'number',
@ -166,7 +166,8 @@ class UserComposer
'column' => 'u.email',
'type' => 'string',
'label' => 'E-Mail'
], [
],
[
'column' => 'u.name',
'type' => 'string',
'label' => 'Name'
@ -187,7 +188,11 @@ class UserComposer
]);
$view->with('datagrid', $datagrid);
// $view->with('count', $this->users->count());
}
public function render() {
return $this->createUserDataGrid()->render();
}
}

View File

@ -6,7 +6,6 @@ use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Blade;
use Webkul\Admin\Providers\EventServiceProvider;
use Webkul\Admin\Providers\ComposerServiceProvider;
class AdminServiceProvider extends ServiceProvider
{
@ -30,7 +29,6 @@ class AdminServiceProvider extends ServiceProvider
$this->composeView();
$this->app->register(EventServiceProvider::class);
$this->app->register(ComposerServiceProvider::class);
}
/**

View File

@ -1,58 +0,0 @@
<?php
namespace Webkul\Admin\Providers;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\ServiceProvider;
use View;
class ComposerServiceProvider extends ServiceProvider
{
/**
* Register bindings in the container.
*
* @return void
*/
public function boot()
{
//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');
//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');
}
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
//
}
}

View File

@ -15,7 +15,8 @@
</div>
<div class="page-content">
{!! $datagrid->render() !!}
@inject('channels','Webkul\Admin\DataGrids\ChannelsDataGrid')
{!! $channels->render() !!}
</div>
</div>
@stop

View File

@ -15,7 +15,8 @@
</div>
<div class="page-content">
{!! $datagrid->render() !!}
@inject('countries','Webkul\Admin\DataGrids\CountryDataGrid')
{!! $countries->render() !!}
</div>
</div>
@stop

View File

@ -15,7 +15,8 @@
</div>
<div class="page-content">
{!! $datagrid->render() !!}
@inject('currencies','Webkul\Admin\DataGrids\CurrenciesDataGrid')
{!! $currencies->render() !!}
</div>
</div>
@stop

View File

@ -19,7 +19,8 @@
</div>
<div class="page-content">
{!! $datagrid->render() !!}
@inject('exchange_rates','Webkul\Admin\DataGrids\ExchangeRatesDataGrid')
{!! $exchange_rates->render() !!}
</div>
</div>
@stop

View File

@ -19,7 +19,8 @@
</div>
<div class="page-content">
{!! $datagrid->render() !!}
@inject('inventory_sources','Webkul\Admin\DataGrids\InventorySourcesDataGrid')
{!! $inventory_sources->render() !!}
</div>
</div>
@stop

View File

@ -15,7 +15,9 @@
</div>
<div class="page-content">
{!! $datagrid->render() !!}
@inject('locales','Webkul\Admin\DataGrids\LocalesDataGrid')
{!! $locales->render() !!}
</div>
</div>
@stop

View File

@ -15,7 +15,8 @@
</div>
<div class="page-content">
{!! $datagrid->render() !!}
@inject('sliders','Webkul\Admin\DataGrids\SliderDataGrid')
{!! $sliders->render() !!}
</div>
</div>
@stop

View File

@ -15,7 +15,8 @@
</div>
<div class="page-content">
{!! $datagrid->render() !!}
@inject('roles','Webkul\Admin\DataGrids\RolesDataGrid')
{!! $roles->render() !!}
</div>
</div>
@stop

View File

@ -20,6 +20,7 @@
<div class="page-content">
@inject('datagrid','Webkul\Admin\DataGrids\UserDataGrid')
{!! $datagrid->render() !!}
{{-- <datetime></datetime> --}}
</div>

View File

@ -7,11 +7,12 @@ use Illuminate\Http\Response;
use Illuminate\Routing\Controller;
/**
* Admin user session controller
* Products Category controller
*
* @author Prashant Singh <prashant.singh852@webkul.com>
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/
class CategoryController extends controller
{

View File

@ -7,7 +7,7 @@ Route::group(['middleware' => ['web']], function () {
])->name('store.home');
Route::get('/product', 'Webkul\Shop\Http\Controllers\CategoryController@index')->defaults('_config', [
'view' => 'shop::store.product.index'
'view' => 'shop::store.product.details.index'
]);
Route::get('/product-review', function() {
@ -15,7 +15,7 @@ Route::group(['middleware' => ['web']], function () {
});
Route::get('/cart', function() {
return view('shop::store.product.cart.index');
return view('shop::store.product.view.cart.index');
});
});

View File

@ -17,7 +17,7 @@ class ComposerServiceProvider extends ServiceProvider
public function boot()
{
//using the class based composers...
View::composer('shop::store.header.index', 'Webkul\Shop\Http\ViewComposers\Categories\CategoryComposer');
View::composer('shop::layouts.header.index', 'Webkul\Shop\Http\ViewComposers\Categories\CategoryComposer');
}
/**

View File

@ -792,8 +792,9 @@ section.product-detail, section.product-review {
margin-top: 30px;
.title-inline {
display: inline-block;
vertical-align: middle;
display: inline-flex;
align-items: center;
justify-content: space-between;
margin-bottom: 20px;
width: 100%;

View File

@ -1,4 +1,4 @@
@extends('shop::store.layouts.master')
@extends('shop::layouts.master')
@section('content-wrapper')
<div class="account-content">
@include('shop::customers.account.partials.sidemenu')

View File

@ -1,4 +1,4 @@
@extends('shop::store.layouts.master')
@extends('shop::layouts.master')
@section('content-wrapper')
<div class="account-content">
@include('shop::customers.account.partials.sidemenu')

View File

@ -1,4 +1,4 @@
@extends('shop::store.layouts.master')
@extends('shop::layouts.master')
@section('content-wrapper')
<div class="content">

View File

@ -1,4 +1,4 @@
@extends('shop::store.layouts.master')
@extends('shop::layouts.master')
@section('content-wrapper')

View File

@ -106,7 +106,7 @@
</div>
<div class="header-bottom">
@include('shop::store.header.nav-menu.navmenu')
@include('shop::layouts.header.nav-menu.navmenu')
</div>
</div>

View File

@ -16,14 +16,14 @@
<body>
<div id="app">
@include('shop::store.header.index')
@include('shop::layouts.header.index')
@yield('slider')
<div class="main-container-wrapper">
<div class="content-container">
@yield('content-wrapper')
</div>
</div>
@include('shop::store.footer.index')
@include('shop::layouts.footer.index')
</div>
<script type="text/javascript">

View File

@ -1,4 +1,4 @@
@extends('shop::store.layouts.master')
@extends('shop::layouts.master')
@section('slider')
@include('shop::store.slider.slider')
@endsection

View File

@ -1,4 +1,4 @@
@extends('shop::store.layouts.master')
@extends('shop::layouts.master')
@section('content-wrapper')
<section class="product-detail">
<div class="category-breadcrumbs">

View File

@ -1,4 +1,4 @@
@extends('shop::store.layouts.master')
@extends('shop::layouts.master')
@section('content-wrapper')
<section class="product-review">
<div class="category-breadcrumbs">

View File

@ -1,4 +1,4 @@
@extends('shop::store.layouts.master')
@extends('shop::layouts.master')
@section('content-wrapper')
<section class="cart">
<div class="title">

View File

@ -12,6 +12,15 @@ use Webkul\Ui\DataGrid\Helpers\Css;
use Webkul\Ui\DataGrid\Helpers\MassAction;
use URL;
/**
* Products DataGrid
*
* @author Prashant Singh <prashant.singh852@webkul.com> @prashant-webkul
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/
class ProductGrid
{
/**