forked from planetadeleste/oc-apishopaholic-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroutes.php
71 lines (59 loc) · 3.24 KB
/
routes.php
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
<?php
use PlanetaDelEste\ApiShopaholic\Plugin;
use System\Classes\PluginManager;
Route::prefix('api/v1')
->namespace('PlanetaDelEste\ApiShopaholic\Controllers\Api')
->middleware(['throttle:120,1', 'bindings'])
->group(
function () {
$bHasOrdersPlugin = PluginManager::instance()->hasPlugin('Lovata.OrdersShopaholic');
$bHasJWTAuthPlugin = PluginManager::instance()->hasPlugin('PlanetaDelEste.JWTAuth');
Route::prefix('categories')
->name('categories.')
->group(plugins_path(Plugin::API_ROUTES.'categories.php'));
Route::prefix('products')
->name('products.')
->group(plugins_path(Plugin::API_ROUTES.'products.php'));
// ORDERS
if ($bHasOrdersPlugin) {
Route::prefix('cart')
->name('cart.')
->group(plugins_path(Plugin::API_ROUTES.'cart.php'));
Route::prefix('orders')
->name('orders.')
->group(plugins_path(Plugin::API_ROUTES.'orders_public.php'));
}
// TRANSLATE
Route::prefix('lang')
->name('lang.')
->group(plugins_path(Plugin::API_ROUTES.'lang.php'));
Route::apiResource('categories', 'Categories', ['only' => ['index', 'show']]);
Route::apiResource('products', 'Products', ['only' => ['index', 'show']]);
Route::apiResource('groups', 'Groups', ['only' => ['index', 'show']]);
Route::apiResource('brands', 'Brands', ['only' => ['index', 'show']]);
if ($bHasJWTAuthPlugin) {
// AUTHENTICATE
Route::prefix('auth')
->name('auth.')
->group(plugins_path(Plugin::API_ROUTES.'auth.php'));
Route::middleware(['jwt.auth'])
->group(
function () use ($bHasOrdersPlugin) {
if ($bHasOrdersPlugin) {
Route::prefix('orders')->group(plugins_path(Plugin::API_ROUTES.'orders.php'));
Route::apiResource('orders', 'Orders', ['only' => ['store', 'update', 'destroy']]);
}
Route::prefix('profile')->group(plugins_path(Plugin::API_ROUTES.'profile.php'));
Route::apiResource('profile', 'Profile');
Route::apiResource('products', 'Products', ['only' => ['store', 'update', 'destroy']]);
Route::apiResource('users', 'Users');
Route::apiResource('categories', 'Categories', ['only' => ['store', 'update', 'destroy']]);
Route::apiResource('files', 'Files', ['only' => ['store', 'update', 'destroy']]);
Route::apiResource('offers', 'Offers', ['only' => ['store', 'update', 'destroy']]);
Route::apiResource('groups', 'Groups', ['only' => ['store', 'update', 'destroy']]);
Route::apiResource('brands', 'Brands', ['only' => ['store', 'update', 'destroy']]);
}
);
}
}
);