1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Pratiksh\Adminetic\Console\Commands; |
4
|
|
|
|
5
|
|
|
use Illuminate\Console\Command; |
6
|
|
|
|
7
|
|
|
class InstallAdmineticCommand extends Command |
8
|
|
|
{ |
9
|
|
|
/** |
10
|
|
|
* The name and signature of the console command. |
11
|
|
|
* |
12
|
|
|
* @var string |
13
|
|
|
*/ |
14
|
|
|
protected $signature = 'install:adminetic'; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* The console command description. |
18
|
|
|
* |
19
|
|
|
* @var string |
20
|
|
|
*/ |
21
|
|
|
protected $description = 'Command to install adminetic'; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Create a new command instance. |
25
|
|
|
* |
26
|
|
|
* @return void |
27
|
|
|
*/ |
28
|
|
|
public function __construct() |
29
|
|
|
{ |
30
|
|
|
parent::__construct(); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Execute the console command. |
35
|
|
|
* |
36
|
|
|
* @return int |
37
|
|
|
*/ |
38
|
|
|
public function handle() |
39
|
|
|
{ |
40
|
|
|
$this->line(" |
41
|
|
|
_ _ _ _ |
42
|
|
|
/\ | | (_) | | (_) |
43
|
|
|
/ \ __| |_ __ ___ _ _ __ ___| |_ _ ___ |
44
|
|
|
/ /\ \ / _` | '_ ` _ \| | '_ \ / _ \ __| |/ __| |
45
|
|
|
/ ____ \ (_| | | | | | | | | | | __/ |_| | (__ |
46
|
|
|
/_/ \_\__,_|_| |_| |_|_|_| |_|\___|\__|_|\___| |
47
|
|
|
"); |
48
|
|
|
$this->call('vendor:publish', [ |
49
|
|
|
'--tag' => ['adminetic-config'], |
50
|
|
|
]); |
51
|
|
|
$this->info('Adminetic config file published ... ✅'); |
52
|
|
|
$this->call('vendor:publish', [ |
53
|
|
|
'--tag' => ['adminetic-assets-files'], |
54
|
|
|
]); |
55
|
|
|
$this->info('Adminetic asset files published ... ✅'); |
56
|
|
|
$this->call('vendor:publish', [ |
57
|
|
|
'--tag' => ['adminetic-static-files'], |
58
|
|
|
]); |
59
|
|
|
$this->info('Adminetic static files published ... ✅'); |
60
|
|
|
$this->addMyMenu(); |
61
|
|
|
$this->info('My Menu Added ... ✅'); |
62
|
|
|
$this->addMyDashboard(); |
63
|
|
|
$this->info('My Dashboard Added ... ✅'); |
64
|
|
|
$this->addAdminServiceProvider(); |
65
|
|
|
$this->info('Header Added ... ✅'); |
66
|
|
|
$this->addHeader(); |
67
|
|
|
$this->info('Footer Added ... ✅'); |
68
|
|
|
$this->addFooter(); |
69
|
|
|
$this->info('Adminetic Installed ... ✅'); |
70
|
|
|
$this->info('Star to the admenictic repo would be appreciated.'); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
private function addAdminServiceProvider() |
74
|
|
|
{ |
75
|
|
|
$adminServiceProviderTemplate = file_get_contents(__DIR__.'/../../Console/Commands/AdminStubs/AdminServiceProvider.stub'); |
76
|
|
|
$adminServiceProviderfile = app_path('Providers/AdminServiceProvider.php'); |
77
|
|
|
file_put_contents($adminServiceProviderfile, $adminServiceProviderTemplate); |
78
|
|
|
if (file_exists($adminServiceProviderfile)) { |
79
|
|
|
$this->info('AdminServiceProvider created successfully ... ✅'); |
80
|
|
|
} else { |
81
|
|
|
$this->error('Failed to create AdminServiceProvider ...'); |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
private function addMyMenu() |
86
|
|
|
{ |
87
|
|
|
$modelTemplate = file_get_contents(__DIR__.'/../../Console/Commands/AdminStubs/MyMenu.stub'); |
88
|
|
|
|
89
|
|
|
if (! file_exists($path = app_path('Services'))) { |
90
|
|
|
mkdir($path, 0777, true); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
$file = app_path('Services/MyMenu.php'); |
94
|
|
|
file_put_contents($file, $modelTemplate); |
95
|
|
|
if (file_exists($file)) { |
96
|
|
|
$this->info('MyMenu created successfully ... ✅'); |
97
|
|
|
} else { |
98
|
|
|
$this->error('Failed to create MyMenu ...'); |
99
|
|
|
} |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
private function addMyDashboard() |
103
|
|
|
{ |
104
|
|
|
$myDashboardTemplate = file_get_contents(__DIR__.'/../../Console/Commands/AdminStubs/MyDashboard.stub'); |
105
|
|
|
$myDashboardIndexTemplate = file_get_contents(__DIR__.'/../../Console/Commands/AdminStubs/DashboardIndex.stub'); |
106
|
|
|
|
107
|
|
|
if (! file_exists($path = app_path('Services'))) { |
108
|
|
|
mkdir($path, 0777, true); |
109
|
|
|
} |
110
|
|
|
if (! file_exists($path = resource_path('views/admin/dashboard'))) { |
111
|
|
|
mkdir($path, 0777, true); |
112
|
|
|
} |
113
|
|
|
if (! file_exists($path = resource_path('views/admin/layouts/modules/dashboard'))) { |
114
|
|
|
mkdir($path, 0777, true); |
115
|
|
|
} |
116
|
|
|
$myDashboardIndexfile = resource_path('views/admin/dashboard/index.blade.php'); |
117
|
|
|
file_put_contents($myDashboardIndexfile, $myDashboardIndexTemplate); |
118
|
|
|
if (file_exists($myDashboardIndexfile)) { |
119
|
|
|
$this->info('MyDashboardIndex created successfully ... ✅'); |
120
|
|
|
} else { |
121
|
|
|
$this->error('Failed to create MyDashboardIndex ...'); |
122
|
|
|
} |
123
|
|
|
$dashboardScript = resource_path('views/admin/layouts/modules/dashboard/scripts.blade.php'); |
124
|
|
|
file_put_contents(resource_path('views/admin/layouts/modules/dashboard/scripts.blade.php'), ''); |
125
|
|
|
if (file_exists($dashboardScript)) { |
126
|
|
|
$this->info('MyDashboardScripts created successfully ... ✅'); |
127
|
|
|
} else { |
128
|
|
|
$this->error('Failed to create MyDashboardScripts ...'); |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
$myDashboardFilefile = app_path('Services/MyDashboard.php'); |
132
|
|
|
file_put_contents($myDashboardFilefile, $myDashboardTemplate); |
133
|
|
|
if (file_exists($myDashboardFilefile)) { |
134
|
|
|
$this->info('MyDashboard created successfully ... ✅'); |
135
|
|
|
} else { |
136
|
|
|
$this->error('Failed to create MyDashboard ...'); |
137
|
|
|
} |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
protected function addHeader() |
141
|
|
|
{ |
142
|
|
|
$myHeaderTemplate = file_get_contents(__DIR__.'/../../Console/Commands/AdminStubs/HeaderView.stub'); |
143
|
|
|
|
144
|
|
|
if (! file_exists($path = resource_path('views/admin/layouts/components'))) { |
145
|
|
|
mkdir($path, 0777, true); |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
$myHeaderFilefile = resource_path('views/admin/layouts/components/header.blade.php'); |
149
|
|
|
file_put_contents($myHeaderFilefile, $myHeaderTemplate); |
150
|
|
|
if (file_exists($myHeaderFilefile)) { |
151
|
|
|
$this->info('Header view created successfully ... ✅'); |
152
|
|
|
} else { |
153
|
|
|
$this->error('Failed to create header view ...'); |
154
|
|
|
} |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
protected function addFooter() |
158
|
|
|
{ |
159
|
|
|
$myFooterTemplate = file_get_contents(__DIR__.'/../../Console/Commands/AdminStubs/FooterView.stub'); |
160
|
|
|
|
161
|
|
|
if (! file_exists($path = resource_path('views/admin/layouts/components'))) { |
162
|
|
|
mkdir($path, 0777, true); |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
$myFooterFilefile = resource_path('views/admin/layouts/components/footer.blade.php'); |
166
|
|
|
file_put_contents($myFooterFilefile, $myFooterTemplate); |
167
|
|
|
if (file_exists($myFooterFilefile)) { |
168
|
|
|
$this->info('Footer view created successfully ... ✅'); |
169
|
|
|
} else { |
170
|
|
|
$this->error('Failed to create footer view ...'); |
171
|
|
|
} |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
protected static function getStub($type) |
175
|
|
|
{ |
176
|
|
|
return file_get_contents(__DIR__."/../../Console/Commands/AdminStubs/$type.stub"); |
177
|
|
|
} |
178
|
|
|
} |
179
|
|
|
|