File tree Expand file tree Collapse file tree 3 files changed +76
-8
lines changed Expand file tree Collapse file tree 3 files changed +76
-8
lines changed Original file line number Diff line number Diff line change 1414 Webfactor \Laravel \Generators \Services \FactoryService::class,
1515 Webfactor \Laravel \Generators \Services \SeederService::class,
1616 Webfactor \Laravel \Generators \Services \RouteService::class,
17+ Webfactor \Laravel \Generators \Services \SidebarService::class,
1718 Webfactor \Laravel \Generators \Services \OpenIdeService::class,
1819 ],
1920
Original file line number Diff line number Diff line change 99
1010class RouteService extends ServiceAbstract implements ServiceInterface
1111{
12- protected $ relativeToBasePath = 'routes ' ;
12+ protected $ relativeToBasePath = 'routes/backpack ' ;
1313
14- private $ adminFile ;
14+ protected $ fileName = 'custom.php ' ;
15+
16+ private $ routeFile ;
1517
1618 public function call ()
1719 {
18- $ this ->adminFile = $ this ->getFilePath ();
20+ $ this ->routeFile = $ this ->getFilePath ();
1921
20- if ($ this ->filesystem ->exists ($ this ->adminFile )) {
22+ if ($ this ->filesystem ->exists ($ this ->routeFile )) {
2123 $ this ->writeFile ();
24+ $ this ->addLatestFileToIdeStack ();
2225 }
23-
24- $ this ->addLatestFileToIdeStack ();
2526 }
2627
2728 private function getRouteName (): string
@@ -43,12 +44,12 @@ private function getControllerName(): string
4344 */
4445 private function writeFile ()
4546 {
46- $ this ->filesystem ->append ($ this ->adminFile , $ this ->getRouteString ());
47+ $ this ->filesystem ->append ($ this ->routeFile , $ this ->getRouteString ());
4748 }
4849
4950 private function getFilePath ()
5051 {
51- return base_path (' routes ' ) . '/admin.php ' ;
52+ return base_path ($ this -> relativeToBasePath ) . '/ ' . $ this -> fileName ;
5253 }
5354
5455 private function getRouteString ()
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Webfactor \Laravel \Generators \Services ;
4+
5+ use Illuminate \Filesystem \Filesystem ;
6+ use Webfactor \Laravel \Generators \Commands \MakeEntity ;
7+ use Webfactor \Laravel \Generators \Contracts \ServiceAbstract ;
8+ use Webfactor \Laravel \Generators \Contracts \ServiceInterface ;
9+
10+ class SidebarService extends ServiceAbstract implements ServiceInterface
11+ {
12+ protected $ relativeToBasePath = 'resources/views/vendor/backpack/base/inc ' ;
13+
14+ protected $ fileName = 'sidebar_content.blade.php ' ;
15+
16+ private $ sidebarFile ;
17+
18+ public function call ()
19+ {
20+ $ this ->sidebarFile = $ this ->getFilePath ();
21+
22+ if ($ this ->filesystem ->exists ($ this ->sidebarFile )) {
23+ $ this ->writeFile ();
24+ $ this ->addLatestFileToIdeStack ();
25+ }
26+ }
27+
28+ private function getRouteName (): string
29+ {
30+ return strtolower ($ this ->command ->entity );
31+ }
32+
33+ private function getLanguageName (): string
34+ {
35+ return snake_case ($ this ->command ->entity );
36+ }
37+
38+ /**
39+ * Build the class with the given name.
40+ *
41+ * @param string $name
42+ *
43+ * @return string
44+ */
45+ private function writeFile ()
46+ {
47+ $ this ->filesystem ->append ($ this ->sidebarFile , $ this ->getRouteString ());
48+ }
49+
50+ private function getFilePath ()
51+ {
52+ return base_path ($ this ->relativeToBasePath ) . '/ ' . $ this ->fileName ;
53+ }
54+
55+ private function getRouteString ()
56+ {
57+ return <<<FILE
58+
59+ <li>
60+ <a href="{{ backpack_url(' {$ this ->getRouteName ()}') }}">
61+ <i class="fa fa-question"></i><span>{{ trans('models. {$ this ->getLanguageName ()}.plural') }}</span>
62+ </a>
63+ </li>
64+ FILE ;
65+ }
66+ }
You can’t perform that action at this time.
0 commit comments