Repository navigation
Expand file tree
/
Copy pathPlugin.php
More file actions
executable file
·219 lines (200 loc) · 6.77 KB
/
Copy pathPlugin.php
File metadata and controls
executable file
·219 lines (200 loc) · 6.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
<?php namespace Pixiu\Commerce;
use Backend;
use Carbon\Carbon;
use Pixiu\Commerce\api\Classes\CategoryTreeAdapter;
use Pixiu\Commerce\api\Classes\CheckoutApi;
use Pixiu\Commerce\api\Enums\CartStatusEnum;
use Pixiu\Commerce\api\Tasks\CheckCarts;
use Pixiu\Commerce\Classes\Invoice\NormalInvoiceManager;
use Pixiu\Commerce\Classes\TaxHandler;
use Pixiu\Commerce\Models\Cart;
use System\Classes\PluginBase;
use Illuminate\Support\Facades\Event;
use RainLab\User\Models\User;
use Barryvdh\DomPDF\ServiceProvider;
use Pixiucz\Invoices\InvoicesServiceProvider;
use Illuminate\Foundation\AliasLoader;
use Illuminate\Support\Facades\Lang;
use Pixiu\Commerce\Classes\CurrencyHandler;
/**
* Commerce Plugin Information File
*/
class Plugin extends PluginBase
{
public $require = [
'RainLab.User'
];
/**
* Returns information about this plugin.
*
* @return array
*/
public function pluginDetails()
{
return [
'name' => 'Commerce',
'description' => 'No description provided yet...',
'author' => 'Pixiu',
'icon' => 'icon-leaf'
];
}
/**
* Register method, called when the plugin is first registered.
*
* @return void
*/
public function register()
{
\App::bind('CurrencyHandler', function($app) {
return new CurrencyHandler;
});
\App::bind('TaxHandler', function($app) {
return new TaxHandler;
});
\App::bind('CategoryTreeAdapter', function($app) {
return new CategoryTreeAdapter;
});
\App::bind('CheckoutApi', function ($app) {
return new CheckoutApi;
});
$this->app->register(InvoicesServiceProvider::class);
}
/**
* Boot method, called right before the request route.
*
* @return array
*/
public function boot()
{
// $this->logQueries();
Event::listen('backend.menu.extendItems', function($manager) {
$manager->removeMainMenuItem('RainLab.User', 'user');
});
User::extend(function($model) {
$model->hasMany['addresses'] = ['Pixiu\Commerce\Models\Address'];
$model->hasMany['orders'] = ['Pixiu\Commerce\Models\Order'];
});
$this->app->register(ServiceProvider::class);
AliasLoader::getInstance()->alias('PDF', 'Barryvdh\DomPDF\Facade');
}
/**
* Registers any front-end components implemented in this plugin.
*
* @return array
*/
public function registerComponents()
{
return []; // Remove this line to activate
return [
'Pixiu\Commerce\Components\MyComponent' => 'myComponent',
];
}
/**
* Registers any back-end permissions used by this plugin.
*
* @return array
*/
public function registerPermissions()
{
return []; // Remove this line to activate
return [
'pixiu.commerce.some_permission' => [
'tab' => 'Commerce',
'label' => 'Some permission'
],
];
}
/**
* Registers back-end navigation items for this plugin.
*
* @return array
*/
public function registerNavigation()
{
return [
'commerce' => [
'label' => 'Commerce',
'url' => Backend::url('pixiu/commerce/Orders'),
'icon' => 'icon-balance-scale',
'permissions' => ['pixiu.commerce.*'],
'order' => 500,
'sideMenu' => [
'orders' => [
'label' => Lang::get('pixiu.commerce::lang.menu.orders'),
'url' => Backend::url('pixiu/commerce/Orders'),
'icon' => 'icon-shopping-basket',
'permissions' => ['pixiu.commerce.*']
],
'products' => [
'label' => Lang::get('pixiu.commerce::lang.menu.products'),
'url' => Backend::url('pixiu/commerce/Products'),
'icon' => 'icon-cube',
'permissions' => ['pixiu.commerce.*']
],
'categories' => [
'label' => Lang::get('pixiu.commerce::lang.menu.categories'),
'url' => Backend::url('pixiu/commerce/Categories'),
'icon' => 'icon-cubes',
'permissions' => ['pixiu.commerce.*']
],
'brands' => [
'label' => Lang::get('pixiu.commerce::lang.menu.brands'),
'url' => Backend::url('pixiu/commerce/Brands'),
'icon' => 'icon-diamond',
'permissions' => ['pixiu.commerce.*']
],
'users' => [
'label' => Lang::get('pixiu.commerce::lang.menu.users'),
'url' => Backend::url('pixiu/commerce/Users'),
'icon' => 'icon-male',
'permissions' => ['pixiu.commerce.*']
],
'taxes' => [
'label' => Lang::get('pixiu.commerce::lang.menu.taxes'),
'url' => Backend::url('pixiu/commerce/Taxes'),
'icon' => 'icon-money',
'permissions' => ['pixiu.commerce.*']
],
]
]
];
}
public function registerSettings()
{
return [
'commerce_settings' => [
'label' => 'eShop settings',
'description' => 'Názov, adresa, IČO,...',
'category' => 'Všeobecné nastavenia',
'icon' => 'icon-cog',
'class' => 'Pixiu\Commerce\Models\CommerceSettings',
'order' => 500,
'keywords' => 'security location',
'permissions' => ['pixiu.turistickeznamky.*']
]
];
}
public function registerSchedule($schedule)
{
$schedule->call(function() {
CheckCarts::run();
})->daily();
}
public function registerFormWidgets()
{
return [
'Pixiu\Commerce\FormWidgets\Currency' => 'currencywidget',
'Pixiu\Commerce\FormWidgets\VariantsWidget' => 'variantswidget'
];
}
private function logQueries()
{
\DB::listen(function($query) {
\Log::info(
$query->sql,
$query->bindings,
$query->time
);
});
}
}