@@ -7,25 +7,25 @@ |
||
7 | 7 | use KielD01\LaravelMaterialDashboardPro\Helpers\MenuItemLinkType; |
8 | 8 | |
9 | 9 | return [ |
10 | - [ |
|
11 | - 'title' => 'Dashboard', |
|
12 | - 'link' => [ |
|
13 | - 'type' => MenuItemLinkType::ROUTE, |
|
14 | - 'route' => 'dashboard.index', |
|
15 | - ], |
|
16 | - 'icon' => [MaterialIcon::class, 'dashboard'], |
|
17 | - ], |
|
18 | - [ |
|
19 | - 'title' => 'Users', |
|
20 | - 'icon' => [FontAwesomeIcon::class, 'login'], |
|
21 | - 'children' => [ |
|
22 | - [ |
|
23 | - 'title' => 'Create User', |
|
24 | - 'link' => [ |
|
25 | - 'type' => MenuItemLinkType::ROUTE, |
|
26 | - 'route' => 'users.create', |
|
27 | - ], |
|
28 | - ] |
|
29 | - ] |
|
30 | - ], |
|
10 | + [ |
|
11 | + 'title' => 'Dashboard', |
|
12 | + 'link' => [ |
|
13 | + 'type' => MenuItemLinkType::ROUTE, |
|
14 | + 'route' => 'dashboard.index', |
|
15 | + ], |
|
16 | + 'icon' => [MaterialIcon::class, 'dashboard'], |
|
17 | + ], |
|
18 | + [ |
|
19 | + 'title' => 'Users', |
|
20 | + 'icon' => [FontAwesomeIcon::class, 'login'], |
|
21 | + 'children' => [ |
|
22 | + [ |
|
23 | + 'title' => 'Create User', |
|
24 | + 'link' => [ |
|
25 | + 'type' => MenuItemLinkType::ROUTE, |
|
26 | + 'route' => 'users.create', |
|
27 | + ], |
|
28 | + ] |
|
29 | + ] |
|
30 | + ], |
|
31 | 31 | ]; |
@@ -6,11 +6,11 @@ |
||
6 | 6 | |
7 | 7 | class DemoMenuVisibilityResolver extends MenuVisibilityResolver |
8 | 8 | { |
9 | - /** |
|
10 | - * @inheritDoc |
|
11 | - */ |
|
12 | - public function resolve(mixed $valueOrValues): bool |
|
13 | - { |
|
14 | - return in_array('sudo', $valueOrValues, true); |
|
15 | - } |
|
9 | + /** |
|
10 | + * @inheritDoc |
|
11 | + */ |
|
12 | + public function resolve(mixed $valueOrValues): bool |
|
13 | + { |
|
14 | + return in_array('sudo', $valueOrValues, true); |
|
15 | + } |
|
16 | 16 | } |
@@ -9,15 +9,15 @@ |
||
9 | 9 | |
10 | 10 | class MdpViewComposer |
11 | 11 | { |
12 | - private MaterialDashboardPro $mdp; |
|
12 | + private MaterialDashboardPro $mdp; |
|
13 | 13 | |
14 | - public function __construct(MaterialDashboardPro $mdp) |
|
15 | - { |
|
16 | - $this->mdp = $mdp; |
|
17 | - } |
|
14 | + public function __construct(MaterialDashboardPro $mdp) |
|
15 | + { |
|
16 | + $this->mdp = $mdp; |
|
17 | + } |
|
18 | 18 | |
19 | - public function compose(View $view): void |
|
20 | - { |
|
21 | - $view->with('mdp', $this->mdp); |
|
22 | - } |
|
19 | + public function compose(View $view): void |
|
20 | + { |
|
21 | + $view->with('mdp', $this->mdp); |
|
22 | + } |
|
23 | 23 | } |
@@ -17,165 +17,165 @@ |
||
17 | 17 | |
18 | 18 | class MenuItem |
19 | 19 | { |
20 | - private Request $request; |
|
21 | - private string $title; |
|
22 | - private string $menuItemLinkType; |
|
23 | - private string $link; |
|
24 | - private string $baseLink; |
|
25 | - private ?Icon $icon; |
|
26 | - private Collection $children; |
|
27 | - private UuidInterface $hash; |
|
28 | - private string $abbr; |
|
29 | - private bool $isChild; |
|
30 | - private array $classes = [ |
|
31 | - 'nav-item', |
|
32 | - ]; |
|
33 | - |
|
34 | - public function __construct( |
|
35 | - string $title, |
|
36 | - string $menuItemLinkType, |
|
37 | - string $link, |
|
38 | - ?Icon $icon = null, |
|
39 | - array $children = [], |
|
40 | - bool $isChild = false |
|
41 | - ) |
|
42 | - { |
|
43 | - $this->title = $title; |
|
44 | - $this->menuItemLinkType = $menuItemLinkType; |
|
45 | - $this->link = $this->baseLink = $link; |
|
46 | - $this->icon = $icon; |
|
47 | - $this->children = collect($children); |
|
48 | - $this->isChild = $isChild; |
|
49 | - $this->hash = Uuid::fromString(md5($this->title)); |
|
50 | - $this->request = resolve(Request::class); |
|
51 | - |
|
52 | - $this->setAbbr(); |
|
53 | - $this->setActive(); |
|
54 | - } |
|
55 | - |
|
56 | - private function setAbbr(): void |
|
57 | - { |
|
58 | - $words = explode(' ', $this->getTitle()); |
|
59 | - |
|
60 | - $abbrArray = array_map( |
|
61 | - static function ($word) { |
|
62 | - $array = mb_str_split($word); |
|
63 | - |
|
64 | - return current($array); |
|
65 | - }, |
|
66 | - $words |
|
67 | - ); |
|
68 | - |
|
69 | - $abbrString = mb_strtoupper(implode('', $abbrArray)); |
|
70 | - |
|
71 | - $this->abbr = preg_replace( |
|
72 | - '/([^0-9A-Za-zА-я])/u', |
|
73 | - '', |
|
74 | - $abbrString |
|
75 | - ); |
|
76 | - } |
|
77 | - |
|
78 | - public function getTitle(): string |
|
79 | - { |
|
80 | - return $this->title; |
|
81 | - } |
|
82 | - |
|
83 | - private function setActive(): void |
|
84 | - { |
|
85 | - /** @var Route $route */ |
|
86 | - $route = $this->request->route(); |
|
87 | - |
|
88 | - if (!is_null($route)) { |
|
89 | - switch ($this->menuItemLinkType) { |
|
90 | - case MenuItemLinkType::ROUTE: |
|
91 | - if ($this->getBaseLink() === $route->getName()) { |
|
92 | - $this->classes[] = 'active'; |
|
93 | - } |
|
94 | - |
|
95 | - break; |
|
96 | - case MenuItemLinkType::URI: |
|
97 | - $match0 = mb_strpos( |
|
98 | - $route->uri(), |
|
99 | - $this->getBaseLink() |
|
100 | - ) === 0; |
|
101 | - |
|
102 | - if ($match0) { |
|
103 | - $this->classes[] = 'active'; |
|
104 | - } |
|
105 | - break; |
|
106 | - } |
|
107 | - } |
|
108 | - } |
|
109 | - |
|
110 | - private function getBaseLink(): string |
|
111 | - { |
|
112 | - return $this->baseLink; |
|
113 | - } |
|
114 | - |
|
115 | - public function getLink(): string |
|
116 | - { |
|
117 | - $uri = '#'; |
|
118 | - |
|
119 | - switch ($this->hasChildren()) { |
|
120 | - case true: |
|
121 | - $uri = sprintf('#%s', $this->getMenuItemHash()); |
|
122 | - break; |
|
123 | - case false: |
|
124 | - switch ($this->menuItemLinkType) { |
|
125 | - case MenuItemLinkType::ROUTE: |
|
126 | - try { |
|
127 | - $uri = route($this->link); |
|
128 | - } catch (Throwable $exception) { |
|
129 | - Log::error(sprintf('Menu Build Item issue : %s', $exception->getMessage())); |
|
130 | - } |
|
131 | - break; |
|
132 | - case MenuItemLinkType::URI: |
|
133 | - $uri = $this->link; |
|
134 | - break; |
|
135 | - } |
|
136 | - break; |
|
137 | - } |
|
138 | - |
|
139 | - return $uri; |
|
140 | - } |
|
141 | - |
|
142 | - public function hasChildren(): bool |
|
143 | - { |
|
144 | - return $this->children->isNotEmpty(); |
|
145 | - } |
|
146 | - |
|
147 | - public function getMenuItemHash(): string |
|
148 | - { |
|
149 | - return $this->hash->toString(); |
|
150 | - } |
|
151 | - |
|
152 | - public function hasIcon(): bool |
|
153 | - { |
|
154 | - return !is_null($this->getIcon()); |
|
155 | - } |
|
156 | - |
|
157 | - public function getIcon(): ?Icon |
|
158 | - { |
|
159 | - return $this->icon; |
|
160 | - } |
|
161 | - |
|
162 | - public function isChild(): bool |
|
163 | - { |
|
164 | - return $this->isChild; |
|
165 | - } |
|
166 | - |
|
167 | - public function getChildren(): Collection |
|
168 | - { |
|
169 | - return $this->children; |
|
170 | - } |
|
171 | - |
|
172 | - public function getAbbr(): string |
|
173 | - { |
|
174 | - return $this->abbr; |
|
175 | - } |
|
176 | - |
|
177 | - public function getClasses(): string |
|
178 | - { |
|
179 | - return implode(' ', $this->classes); |
|
180 | - } |
|
20 | + private Request $request; |
|
21 | + private string $title; |
|
22 | + private string $menuItemLinkType; |
|
23 | + private string $link; |
|
24 | + private string $baseLink; |
|
25 | + private ?Icon $icon; |
|
26 | + private Collection $children; |
|
27 | + private UuidInterface $hash; |
|
28 | + private string $abbr; |
|
29 | + private bool $isChild; |
|
30 | + private array $classes = [ |
|
31 | + 'nav-item', |
|
32 | + ]; |
|
33 | + |
|
34 | + public function __construct( |
|
35 | + string $title, |
|
36 | + string $menuItemLinkType, |
|
37 | + string $link, |
|
38 | + ?Icon $icon = null, |
|
39 | + array $children = [], |
|
40 | + bool $isChild = false |
|
41 | + ) |
|
42 | + { |
|
43 | + $this->title = $title; |
|
44 | + $this->menuItemLinkType = $menuItemLinkType; |
|
45 | + $this->link = $this->baseLink = $link; |
|
46 | + $this->icon = $icon; |
|
47 | + $this->children = collect($children); |
|
48 | + $this->isChild = $isChild; |
|
49 | + $this->hash = Uuid::fromString(md5($this->title)); |
|
50 | + $this->request = resolve(Request::class); |
|
51 | + |
|
52 | + $this->setAbbr(); |
|
53 | + $this->setActive(); |
|
54 | + } |
|
55 | + |
|
56 | + private function setAbbr(): void |
|
57 | + { |
|
58 | + $words = explode(' ', $this->getTitle()); |
|
59 | + |
|
60 | + $abbrArray = array_map( |
|
61 | + static function ($word) { |
|
62 | + $array = mb_str_split($word); |
|
63 | + |
|
64 | + return current($array); |
|
65 | + }, |
|
66 | + $words |
|
67 | + ); |
|
68 | + |
|
69 | + $abbrString = mb_strtoupper(implode('', $abbrArray)); |
|
70 | + |
|
71 | + $this->abbr = preg_replace( |
|
72 | + '/([^0-9A-Za-zА-я])/u', |
|
73 | + '', |
|
74 | + $abbrString |
|
75 | + ); |
|
76 | + } |
|
77 | + |
|
78 | + public function getTitle(): string |
|
79 | + { |
|
80 | + return $this->title; |
|
81 | + } |
|
82 | + |
|
83 | + private function setActive(): void |
|
84 | + { |
|
85 | + /** @var Route $route */ |
|
86 | + $route = $this->request->route(); |
|
87 | + |
|
88 | + if (!is_null($route)) { |
|
89 | + switch ($this->menuItemLinkType) { |
|
90 | + case MenuItemLinkType::ROUTE: |
|
91 | + if ($this->getBaseLink() === $route->getName()) { |
|
92 | + $this->classes[] = 'active'; |
|
93 | + } |
|
94 | + |
|
95 | + break; |
|
96 | + case MenuItemLinkType::URI: |
|
97 | + $match0 = mb_strpos( |
|
98 | + $route->uri(), |
|
99 | + $this->getBaseLink() |
|
100 | + ) === 0; |
|
101 | + |
|
102 | + if ($match0) { |
|
103 | + $this->classes[] = 'active'; |
|
104 | + } |
|
105 | + break; |
|
106 | + } |
|
107 | + } |
|
108 | + } |
|
109 | + |
|
110 | + private function getBaseLink(): string |
|
111 | + { |
|
112 | + return $this->baseLink; |
|
113 | + } |
|
114 | + |
|
115 | + public function getLink(): string |
|
116 | + { |
|
117 | + $uri = '#'; |
|
118 | + |
|
119 | + switch ($this->hasChildren()) { |
|
120 | + case true: |
|
121 | + $uri = sprintf('#%s', $this->getMenuItemHash()); |
|
122 | + break; |
|
123 | + case false: |
|
124 | + switch ($this->menuItemLinkType) { |
|
125 | + case MenuItemLinkType::ROUTE: |
|
126 | + try { |
|
127 | + $uri = route($this->link); |
|
128 | + } catch (Throwable $exception) { |
|
129 | + Log::error(sprintf('Menu Build Item issue : %s', $exception->getMessage())); |
|
130 | + } |
|
131 | + break; |
|
132 | + case MenuItemLinkType::URI: |
|
133 | + $uri = $this->link; |
|
134 | + break; |
|
135 | + } |
|
136 | + break; |
|
137 | + } |
|
138 | + |
|
139 | + return $uri; |
|
140 | + } |
|
141 | + |
|
142 | + public function hasChildren(): bool |
|
143 | + { |
|
144 | + return $this->children->isNotEmpty(); |
|
145 | + } |
|
146 | + |
|
147 | + public function getMenuItemHash(): string |
|
148 | + { |
|
149 | + return $this->hash->toString(); |
|
150 | + } |
|
151 | + |
|
152 | + public function hasIcon(): bool |
|
153 | + { |
|
154 | + return !is_null($this->getIcon()); |
|
155 | + } |
|
156 | + |
|
157 | + public function getIcon(): ?Icon |
|
158 | + { |
|
159 | + return $this->icon; |
|
160 | + } |
|
161 | + |
|
162 | + public function isChild(): bool |
|
163 | + { |
|
164 | + return $this->isChild; |
|
165 | + } |
|
166 | + |
|
167 | + public function getChildren(): Collection |
|
168 | + { |
|
169 | + return $this->children; |
|
170 | + } |
|
171 | + |
|
172 | + public function getAbbr(): string |
|
173 | + { |
|
174 | + return $this->abbr; |
|
175 | + } |
|
176 | + |
|
177 | + public function getClasses(): string |
|
178 | + { |
|
179 | + return implode(' ', $this->classes); |
|
180 | + } |
|
181 | 181 | } |
@@ -11,33 +11,33 @@ |
||
11 | 11 | |
12 | 12 | class TestAuthController extends Controller |
13 | 13 | { |
14 | - public function login(): string |
|
15 | - { |
|
16 | - return view('mdp::pages.user.login')->render(); |
|
17 | - } |
|
18 | - |
|
19 | - public function auth(Request $request): RedirectResponse |
|
20 | - { |
|
21 | - $credentials = [ |
|
22 | - 'email' => $request->post('email'), |
|
23 | - 'password' => $request->post('password') |
|
24 | - ]; |
|
25 | - |
|
26 | - $emailCheck = Str::is('[email protected]', $credentials['email']); |
|
27 | - $passwordCheck = Str::is('adminTest!123', $credentials['password']); |
|
28 | - $checksPassed = $emailCheck && $passwordCheck; |
|
29 | - |
|
30 | - if ($checksPassed) { |
|
31 | - return redirect(route('kield01.mdp.dashboard.index')); |
|
32 | - } |
|
33 | - |
|
34 | - return redirect() |
|
35 | - ->back() |
|
36 | - ->with($credentials); |
|
37 | - } |
|
38 | - |
|
39 | - public function register(): string |
|
40 | - { |
|
41 | - return view('mdp::pages.user.register')->render(); |
|
42 | - } |
|
14 | + public function login(): string |
|
15 | + { |
|
16 | + return view('mdp::pages.user.login')->render(); |
|
17 | + } |
|
18 | + |
|
19 | + public function auth(Request $request): RedirectResponse |
|
20 | + { |
|
21 | + $credentials = [ |
|
22 | + 'email' => $request->post('email'), |
|
23 | + 'password' => $request->post('password') |
|
24 | + ]; |
|
25 | + |
|
26 | + $emailCheck = Str::is('[email protected]', $credentials['email']); |
|
27 | + $passwordCheck = Str::is('adminTest!123', $credentials['password']); |
|
28 | + $checksPassed = $emailCheck && $passwordCheck; |
|
29 | + |
|
30 | + if ($checksPassed) { |
|
31 | + return redirect(route('kield01.mdp.dashboard.index')); |
|
32 | + } |
|
33 | + |
|
34 | + return redirect() |
|
35 | + ->back() |
|
36 | + ->with($credentials); |
|
37 | + } |
|
38 | + |
|
39 | + public function register(): string |
|
40 | + { |
|
41 | + return view('mdp::pages.user.register')->render(); |
|
42 | + } |
|
43 | 43 | } |
@@ -13,138 +13,138 @@ |
||
13 | 13 | |
14 | 14 | class CoreServiceProvider extends ServiceProvider |
15 | 15 | { |
16 | - public const VIEWS_NAMESPACE = 'mdp'; |
|
17 | - |
|
18 | - public function register(): void |
|
19 | - { |
|
20 | - } |
|
21 | - |
|
22 | - public function boot(Factory $view): void |
|
23 | - { |
|
24 | - $this->registerPublishableConfigs(); |
|
25 | - $this->registerPublishableAssets(); |
|
26 | - $this->registerViews(); |
|
27 | - $this->registerViewComposers($view); |
|
28 | - $this->registerRoutes(); |
|
29 | - $this->registerLocales(); |
|
30 | - $this->registerComponents(); |
|
31 | - } |
|
32 | - |
|
33 | - /** |
|
34 | - * @return void |
|
35 | - */ |
|
36 | - public function registerComponents(): void |
|
37 | - { |
|
38 | - /** @var ComponentRegistrar $registrar */ |
|
39 | - $registrar = resolve(ComponentRegistrar::class); |
|
40 | - $registrar->register(); |
|
41 | - } |
|
42 | - |
|
43 | - public function registerPublishableConfigs(): void |
|
44 | - { |
|
45 | - $baseDir = __DIR__ . DIRECTORY_SEPARATOR . '..'; |
|
46 | - $configs = sprintf('%s%s%s', $baseDir, DIRECTORY_SEPARATOR, 'config'); |
|
47 | - $mdpCoreConfig = sprintf( |
|
48 | - '%s%s%s%s%s', |
|
49 | - $configs, |
|
50 | - DIRECTORY_SEPARATOR, |
|
51 | - 'mdp', |
|
52 | - DIRECTORY_SEPARATOR, |
|
53 | - 'core.php' |
|
54 | - ); |
|
55 | - |
|
56 | - $mdpMenuConfig = sprintf( |
|
57 | - '%s%s%s%s%s', |
|
58 | - $configs, |
|
59 | - DIRECTORY_SEPARATOR, |
|
60 | - 'mdp', |
|
61 | - DIRECTORY_SEPARATOR, |
|
62 | - 'menu.php' |
|
63 | - ); |
|
64 | - |
|
65 | - $this->publishes( |
|
66 | - [ |
|
67 | - $mdpCoreConfig => config_path( |
|
68 | - sprintf( |
|
69 | - '%s%s%s', |
|
70 | - 'mdp', |
|
71 | - DIRECTORY_SEPARATOR, |
|
72 | - 'core.php' |
|
73 | - ) |
|
74 | - ), |
|
75 | - $mdpMenuConfig => config_path( |
|
76 | - sprintf( |
|
77 | - '%s%s%s', |
|
78 | - 'mdp', |
|
79 | - DIRECTORY_SEPARATOR, |
|
80 | - 'menu.php' |
|
81 | - ) |
|
82 | - ), |
|
83 | - ] |
|
84 | - ); |
|
85 | - } |
|
86 | - |
|
87 | - public function registerPublishableAssets(): void |
|
88 | - { |
|
89 | - $packagePublic = __DIR__ . DIRECTORY_SEPARATOR . |
|
90 | - '..' . DIRECTORY_SEPARATOR . |
|
91 | - 'resources' . DIRECTORY_SEPARATOR . |
|
92 | - 'assets'; |
|
93 | - |
|
94 | - $this->publishes( |
|
95 | - [ |
|
96 | - $packagePublic => public_path('assets/mdp'), |
|
97 | - ] |
|
98 | - ); |
|
99 | - } |
|
100 | - |
|
101 | - public function registerViews(): void |
|
102 | - { |
|
103 | - $this->loadViewsFrom( |
|
104 | - __DIR__ . DIRECTORY_SEPARATOR . |
|
105 | - '..' . DIRECTORY_SEPARATOR . |
|
106 | - 'resources' . DIRECTORY_SEPARATOR . |
|
107 | - 'views', |
|
108 | - static::VIEWS_NAMESPACE |
|
109 | - ); |
|
110 | - } |
|
111 | - |
|
112 | - public function registerViewComposers(Factory $view): void |
|
113 | - { |
|
114 | - $view->composer('mdp::layouts.user.auth-v1', MdpViewComposer::class); |
|
115 | - $view->composer('mdp::layouts.main', MdpViewComposer::class); |
|
116 | - } |
|
117 | - |
|
118 | - public function registerRoutes(): void |
|
119 | - { |
|
120 | - if (Config::get('mdp.core.module.routes.enabled', false)) { |
|
121 | - $this->loadRoutesFrom( |
|
122 | - __DIR__ . DIRECTORY_SEPARATOR . |
|
123 | - '..' . DIRECTORY_SEPARATOR . |
|
124 | - 'routes' . DIRECTORY_SEPARATOR . |
|
125 | - 'mdp' . DIRECTORY_SEPARATOR . |
|
126 | - 'auth.php' |
|
127 | - ); |
|
128 | - |
|
129 | - $this->loadRoutesFrom( |
|
130 | - __DIR__ . DIRECTORY_SEPARATOR . |
|
131 | - '..' . DIRECTORY_SEPARATOR . |
|
132 | - 'routes' . DIRECTORY_SEPARATOR . |
|
133 | - 'mdp' . DIRECTORY_SEPARATOR . |
|
134 | - 'dashboard.php' |
|
135 | - ); |
|
136 | - } |
|
137 | - } |
|
138 | - |
|
139 | - public function registerLocales(): void |
|
140 | - { |
|
141 | - $baseDir = __DIR__ . DIRECTORY_SEPARATOR . '..'; |
|
142 | - $locales = sprintf('%s%s%s', $baseDir, DIRECTORY_SEPARATOR, 'lang'); |
|
143 | - |
|
144 | - $this->publishes([ |
|
145 | - sprintf('%s/%s/mdp.php', $locales, 'ua') => lang_path(sprintf('%s/mdp.php', 'ua')), |
|
146 | - sprintf('%s/%s/mdp.php', $locales, 'en') => lang_path(sprintf('%s/mdp.php', 'en')), |
|
147 | - sprintf('%s/%s/mdp.php', $locales, 'kz') => lang_path(sprintf('%s/mdp.php', 'kz')), |
|
148 | - ]); |
|
149 | - } |
|
16 | + public const VIEWS_NAMESPACE = 'mdp'; |
|
17 | + |
|
18 | + public function register(): void |
|
19 | + { |
|
20 | + } |
|
21 | + |
|
22 | + public function boot(Factory $view): void |
|
23 | + { |
|
24 | + $this->registerPublishableConfigs(); |
|
25 | + $this->registerPublishableAssets(); |
|
26 | + $this->registerViews(); |
|
27 | + $this->registerViewComposers($view); |
|
28 | + $this->registerRoutes(); |
|
29 | + $this->registerLocales(); |
|
30 | + $this->registerComponents(); |
|
31 | + } |
|
32 | + |
|
33 | + /** |
|
34 | + * @return void |
|
35 | + */ |
|
36 | + public function registerComponents(): void |
|
37 | + { |
|
38 | + /** @var ComponentRegistrar $registrar */ |
|
39 | + $registrar = resolve(ComponentRegistrar::class); |
|
40 | + $registrar->register(); |
|
41 | + } |
|
42 | + |
|
43 | + public function registerPublishableConfigs(): void |
|
44 | + { |
|
45 | + $baseDir = __DIR__ . DIRECTORY_SEPARATOR . '..'; |
|
46 | + $configs = sprintf('%s%s%s', $baseDir, DIRECTORY_SEPARATOR, 'config'); |
|
47 | + $mdpCoreConfig = sprintf( |
|
48 | + '%s%s%s%s%s', |
|
49 | + $configs, |
|
50 | + DIRECTORY_SEPARATOR, |
|
51 | + 'mdp', |
|
52 | + DIRECTORY_SEPARATOR, |
|
53 | + 'core.php' |
|
54 | + ); |
|
55 | + |
|
56 | + $mdpMenuConfig = sprintf( |
|
57 | + '%s%s%s%s%s', |
|
58 | + $configs, |
|
59 | + DIRECTORY_SEPARATOR, |
|
60 | + 'mdp', |
|
61 | + DIRECTORY_SEPARATOR, |
|
62 | + 'menu.php' |
|
63 | + ); |
|
64 | + |
|
65 | + $this->publishes( |
|
66 | + [ |
|
67 | + $mdpCoreConfig => config_path( |
|
68 | + sprintf( |
|
69 | + '%s%s%s', |
|
70 | + 'mdp', |
|
71 | + DIRECTORY_SEPARATOR, |
|
72 | + 'core.php' |
|
73 | + ) |
|
74 | + ), |
|
75 | + $mdpMenuConfig => config_path( |
|
76 | + sprintf( |
|
77 | + '%s%s%s', |
|
78 | + 'mdp', |
|
79 | + DIRECTORY_SEPARATOR, |
|
80 | + 'menu.php' |
|
81 | + ) |
|
82 | + ), |
|
83 | + ] |
|
84 | + ); |
|
85 | + } |
|
86 | + |
|
87 | + public function registerPublishableAssets(): void |
|
88 | + { |
|
89 | + $packagePublic = __DIR__ . DIRECTORY_SEPARATOR . |
|
90 | + '..' . DIRECTORY_SEPARATOR . |
|
91 | + 'resources' . DIRECTORY_SEPARATOR . |
|
92 | + 'assets'; |
|
93 | + |
|
94 | + $this->publishes( |
|
95 | + [ |
|
96 | + $packagePublic => public_path('assets/mdp'), |
|
97 | + ] |
|
98 | + ); |
|
99 | + } |
|
100 | + |
|
101 | + public function registerViews(): void |
|
102 | + { |
|
103 | + $this->loadViewsFrom( |
|
104 | + __DIR__ . DIRECTORY_SEPARATOR . |
|
105 | + '..' . DIRECTORY_SEPARATOR . |
|
106 | + 'resources' . DIRECTORY_SEPARATOR . |
|
107 | + 'views', |
|
108 | + static::VIEWS_NAMESPACE |
|
109 | + ); |
|
110 | + } |
|
111 | + |
|
112 | + public function registerViewComposers(Factory $view): void |
|
113 | + { |
|
114 | + $view->composer('mdp::layouts.user.auth-v1', MdpViewComposer::class); |
|
115 | + $view->composer('mdp::layouts.main', MdpViewComposer::class); |
|
116 | + } |
|
117 | + |
|
118 | + public function registerRoutes(): void |
|
119 | + { |
|
120 | + if (Config::get('mdp.core.module.routes.enabled', false)) { |
|
121 | + $this->loadRoutesFrom( |
|
122 | + __DIR__ . DIRECTORY_SEPARATOR . |
|
123 | + '..' . DIRECTORY_SEPARATOR . |
|
124 | + 'routes' . DIRECTORY_SEPARATOR . |
|
125 | + 'mdp' . DIRECTORY_SEPARATOR . |
|
126 | + 'auth.php' |
|
127 | + ); |
|
128 | + |
|
129 | + $this->loadRoutesFrom( |
|
130 | + __DIR__ . DIRECTORY_SEPARATOR . |
|
131 | + '..' . DIRECTORY_SEPARATOR . |
|
132 | + 'routes' . DIRECTORY_SEPARATOR . |
|
133 | + 'mdp' . DIRECTORY_SEPARATOR . |
|
134 | + 'dashboard.php' |
|
135 | + ); |
|
136 | + } |
|
137 | + } |
|
138 | + |
|
139 | + public function registerLocales(): void |
|
140 | + { |
|
141 | + $baseDir = __DIR__ . DIRECTORY_SEPARATOR . '..'; |
|
142 | + $locales = sprintf('%s%s%s', $baseDir, DIRECTORY_SEPARATOR, 'lang'); |
|
143 | + |
|
144 | + $this->publishes([ |
|
145 | + sprintf('%s/%s/mdp.php', $locales, 'ua') => lang_path(sprintf('%s/mdp.php', 'ua')), |
|
146 | + sprintf('%s/%s/mdp.php', $locales, 'en') => lang_path(sprintf('%s/mdp.php', 'en')), |
|
147 | + sprintf('%s/%s/mdp.php', $locales, 'kz') => lang_path(sprintf('%s/mdp.php', 'kz')), |
|
148 | + ]); |
|
149 | + } |
|
150 | 150 | } |
@@ -6,10 +6,10 @@ |
||
6 | 6 | |
7 | 7 | abstract class Component extends \Illuminate\View\Component |
8 | 8 | { |
9 | - protected static string $name; |
|
9 | + protected static string $name; |
|
10 | 10 | |
11 | - public static function getComponentName(): string |
|
12 | - { |
|
13 | - return self::$name; |
|
14 | - } |
|
11 | + public static function getComponentName(): string |
|
12 | + { |
|
13 | + return self::$name; |
|
14 | + } |
|
15 | 15 | } |
16 | 16 | \ No newline at end of file |
@@ -7,24 +7,24 @@ |
||
7 | 7 | class CardWidget extends Component |
8 | 8 | { |
9 | 9 | |
10 | - protected static string $name = 'card-widget'; |
|
10 | + protected static string $name = 'card-widget'; |
|
11 | 11 | |
12 | - public function __construct(public string $title, public string $description) |
|
13 | - { |
|
14 | - } |
|
12 | + public function __construct(public string $title, public string $description) |
|
13 | + { |
|
14 | + } |
|
15 | 15 | |
16 | - /** |
|
17 | - * @inheritDoc |
|
18 | - */ |
|
19 | - public function render(): string |
|
20 | - { |
|
21 | - return view( |
|
22 | - sprintf( |
|
23 | - '%s::%s', |
|
24 | - CoreServiceProvider::VIEWS_NAMESPACE, |
|
25 | - 'elements.widgets.simple-card' |
|
26 | - ) |
|
27 | - ) |
|
28 | - ->render(); |
|
29 | - } |
|
16 | + /** |
|
17 | + * @inheritDoc |
|
18 | + */ |
|
19 | + public function render(): string |
|
20 | + { |
|
21 | + return view( |
|
22 | + sprintf( |
|
23 | + '%s::%s', |
|
24 | + CoreServiceProvider::VIEWS_NAMESPACE, |
|
25 | + 'elements.widgets.simple-card' |
|
26 | + ) |
|
27 | + ) |
|
28 | + ->render(); |
|
29 | + } |
|
30 | 30 | } |
31 | 31 | \ No newline at end of file |
@@ -7,20 +7,20 @@ |
||
7 | 7 | |
8 | 8 | final class ComponentRegistrar |
9 | 9 | { |
10 | - private array $components = [ |
|
11 | - CardWidget::class |
|
12 | - ]; |
|
10 | + private array $components = [ |
|
11 | + CardWidget::class |
|
12 | + ]; |
|
13 | 13 | |
14 | - public function register(): void |
|
15 | - { |
|
16 | - array_map( |
|
17 | - fn(string $class) => Blade::component( |
|
18 | - forward_static_call( |
|
19 | - sprintf('%s::getComponentName', $class) |
|
20 | - ), |
|
21 | - $class |
|
22 | - ), |
|
23 | - $this->components |
|
24 | - ); |
|
25 | - } |
|
14 | + public function register(): void |
|
15 | + { |
|
16 | + array_map( |
|
17 | + fn(string $class) => Blade::component( |
|
18 | + forward_static_call( |
|
19 | + sprintf('%s::getComponentName', $class) |
|
20 | + ), |
|
21 | + $class |
|
22 | + ), |
|
23 | + $this->components |
|
24 | + ); |
|
25 | + } |
|
26 | 26 | } |
27 | 27 | \ No newline at end of file |