1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Ikechukwukalu\Magicmake\Console\Commands; |
4
|
|
|
|
5
|
|
|
use Illuminate\Console\Command; |
6
|
|
|
use Illuminate\Filesystem\Filesystem; |
7
|
|
|
use Illuminate\Support\Str; |
8
|
|
|
use Symfony\Component\Finder\SplFileInfo; |
9
|
|
|
|
10
|
|
|
class InitCommands extends Command |
11
|
|
|
{ |
12
|
|
|
|
13
|
|
|
protected function handleAppActionPath() |
14
|
|
|
{ |
15
|
|
|
if (! is_dir($directory = app_path('Actions'))) { |
16
|
|
|
mkdir($directory, 0755, true); |
17
|
|
|
} |
18
|
|
|
|
19
|
|
|
$filesystem = new Filesystem; |
20
|
|
|
|
21
|
|
|
collect($filesystem->allFiles(__DIR__.'/stubs/init/app/Actions')) |
|
|
|
|
22
|
|
|
->each(function (SplFileInfo $file) use ($filesystem) { |
23
|
|
|
$filesystem->copy( |
24
|
|
|
$file->getPathname(), |
25
|
|
|
app_path('Actions/'.Str::replaceLast('.stub', '.php', $file->getFilename())) |
26
|
|
|
); |
27
|
|
|
}); |
28
|
|
|
|
29
|
|
|
$this->components->info('Action classes scaffolding generated successfully.'); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
protected function handleAppContractsPath() |
33
|
|
|
{ |
34
|
|
|
if (! is_dir($directory = app_path('Contracts'))) { |
35
|
|
|
mkdir($directory, 0755, true); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
$filesystem = new Filesystem; |
39
|
|
|
|
40
|
|
|
collect($filesystem->allFiles(__DIR__.'/stubs/init/app/Contracts')) |
|
|
|
|
41
|
|
|
->each(function (SplFileInfo $file) use ($filesystem) { |
42
|
|
|
$filesystem->copy( |
43
|
|
|
$file->getPathname(), |
44
|
|
|
app_path('Contracts/'.Str::replaceLast('.stub', '.php', $file->getFilename())) |
45
|
|
|
); |
46
|
|
|
}); |
47
|
|
|
|
48
|
|
|
$this->components->info('Contract classes scaffolding generated successfully.'); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
protected function handleAppEnumsPath() |
52
|
|
|
{ |
53
|
|
|
if (! is_dir($directory = app_path('Enums'))) { |
54
|
|
|
mkdir($directory, 0755, true); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
$filesystem = new Filesystem; |
58
|
|
|
|
59
|
|
|
collect($filesystem->allFiles(__DIR__.'/stubs/init/app/Enums')) |
|
|
|
|
60
|
|
|
->each(function (SplFileInfo $file) use ($filesystem) { |
61
|
|
|
$filesystem->copy( |
62
|
|
|
$file->getPathname(), |
63
|
|
|
app_path('Enums/'.Str::replaceLast('.stub', '.php', $file->getFilename())) |
64
|
|
|
); |
65
|
|
|
}); |
66
|
|
|
|
67
|
|
|
$this->components->info('Enum classes scaffolding generated successfully.'); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
protected function handleAppEventsPath() |
71
|
|
|
{ |
72
|
|
|
if (! is_dir($directory = app_path('Events'))) { |
73
|
|
|
mkdir($directory, 0755, true); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
$filesystem = new Filesystem; |
77
|
|
|
|
78
|
|
|
collect($filesystem->allFiles(__DIR__.'/stubs/init/app/Events')) |
|
|
|
|
79
|
|
|
->each(function (SplFileInfo $file) use ($filesystem) { |
80
|
|
|
$filesystem->copy( |
81
|
|
|
$file->getPathname(), |
82
|
|
|
app_path('Events/'.Str::replaceLast('.stub', '.php', $file->getFilename())) |
83
|
|
|
); |
84
|
|
|
}); |
85
|
|
|
|
86
|
|
|
$this->components->info('Event classes scaffolding generated successfully.'); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
protected function handleAppExceptionsPath() |
90
|
|
|
{ |
91
|
|
|
if (! is_dir($directory = app_path('Exceptions'))) { |
92
|
|
|
mkdir($directory, 0755, true); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
$filesystem = new Filesystem; |
96
|
|
|
|
97
|
|
|
collect($filesystem->allFiles(__DIR__.'/stubs/init/app/Exceptions')) |
|
|
|
|
98
|
|
|
->each(function (SplFileInfo $file) use ($filesystem) { |
99
|
|
|
$filesystem->copy( |
100
|
|
|
$file->getPathname(), |
101
|
|
|
app_path('Exceptions/'.Str::replaceLast('.stub', '.php', $file->getFilename())) |
102
|
|
|
); |
103
|
|
|
}); |
104
|
|
|
|
105
|
|
|
$this->components->info('Exception classes scaffolding generated successfully.'); |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
protected function handleAppHttpPath() |
109
|
|
|
{ |
110
|
|
|
if (! is_dir($directory = app_path('Http'))) { |
111
|
|
|
mkdir($directory, 0755, true); |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
$filesystem = new Filesystem; |
115
|
|
|
|
116
|
|
|
collect($filesystem->allFiles(__DIR__.'/stubs/init/app/Http')) |
|
|
|
|
117
|
|
|
->each(function (SplFileInfo $file) use ($filesystem) { |
118
|
|
|
$filesystem->copy( |
119
|
|
|
$file->getPathname(), |
120
|
|
|
app_path('Http/'.Str::replaceLast('.stub', '.php', $file->getFilename())) |
121
|
|
|
); |
122
|
|
|
}); |
123
|
|
|
|
124
|
|
|
$this->components->info('Http classes scaffolding generated successfully.'); |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
protected function handleAppHttpControllersPath() |
128
|
|
|
{ |
129
|
|
|
if (! is_dir($directory = app_path('Http/Controllers'))) { |
130
|
|
|
mkdir($directory, 0755, true); |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
$filesystem = new Filesystem; |
134
|
|
|
|
135
|
|
|
collect($filesystem->allFiles(__DIR__.'/stubs/init/app/Controllers')) |
|
|
|
|
136
|
|
|
->each(function (SplFileInfo $file) use ($filesystem) { |
137
|
|
|
$filesystem->copy( |
138
|
|
|
$file->getPathname(), |
139
|
|
|
app_path('Http/Controllers/'.Str::replaceLast('.stub', '.php', $file->getFilename())) |
140
|
|
|
); |
141
|
|
|
}); |
142
|
|
|
|
143
|
|
|
$this->components->info('Http/Controllers classes scaffolding generated successfully.'); |
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
protected function handleAppHttpControllersAuthPath() |
147
|
|
|
{ |
148
|
|
|
if (! is_dir($directory = app_path('Http/Controllers/Auth'))) { |
149
|
|
|
mkdir($directory, 0755, true); |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
$filesystem = new Filesystem; |
153
|
|
|
|
154
|
|
|
collect($filesystem->allFiles(__DIR__.'/stubs/init/app/AuthControllers')) |
|
|
|
|
155
|
|
|
->each(function (SplFileInfo $file) use ($filesystem) { |
156
|
|
|
$filesystem->copy( |
157
|
|
|
$file->getPathname(), |
158
|
|
|
app_path('Http/Controllers/Auth/'.Str::replaceLast('.stub', '.php', $file->getFilename())) |
159
|
|
|
); |
160
|
|
|
}); |
161
|
|
|
|
162
|
|
|
$this->components->info('Http/Controllers/Auth classes scaffolding generated successfully.'); |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
protected function handleAppHttpMiddlewarePath() |
166
|
|
|
{ |
167
|
|
|
if (! is_dir($directory = app_path('Http/Middleware'))) { |
168
|
|
|
mkdir($directory, 0755, true); |
169
|
|
|
} |
170
|
|
|
|
171
|
|
|
$filesystem = new Filesystem; |
172
|
|
|
|
173
|
|
|
collect($filesystem->allFiles(__DIR__.'/stubs/init/app/Middleware')) |
|
|
|
|
174
|
|
|
->each(function (SplFileInfo $file) use ($filesystem) { |
175
|
|
|
$filesystem->copy( |
176
|
|
|
$file->getPathname(), |
177
|
|
|
app_path('Http/Middleware/'.Str::replaceLast('.stub', '.php', $file->getFilename())) |
178
|
|
|
); |
179
|
|
|
}); |
180
|
|
|
|
181
|
|
|
$this->components->info('Http/Middleware classes scaffolding generated successfully.'); |
182
|
|
|
} |
183
|
|
|
|
184
|
|
|
protected function handleAppHttpRequestsPath() |
185
|
|
|
{ |
186
|
|
|
if (! is_dir($directory = app_path('Http/Requests'))) { |
187
|
|
|
mkdir($directory, 0755, true); |
188
|
|
|
} |
189
|
|
|
|
190
|
|
|
$filesystem = new Filesystem; |
191
|
|
|
|
192
|
|
|
collect($filesystem->allFiles(__DIR__.'/stubs/init/app/Requests')) |
|
|
|
|
193
|
|
|
->each(function (SplFileInfo $file) use ($filesystem) { |
194
|
|
|
$filesystem->copy( |
195
|
|
|
$file->getPathname(), |
196
|
|
|
app_path('Http/Requests/'.Str::replaceLast('.stub', '.php', $file->getFilename())) |
197
|
|
|
); |
198
|
|
|
}); |
199
|
|
|
|
200
|
|
|
$this->components->info('Http/Requests classes scaffolding generated successfully.'); |
201
|
|
|
} |
202
|
|
|
|
203
|
|
|
protected function handleAppHttpRequestsAuthPath() |
204
|
|
|
{ |
205
|
|
|
if (! is_dir($directory = app_path('Http/Requests/Auth'))) { |
206
|
|
|
mkdir($directory, 0755, true); |
207
|
|
|
} |
208
|
|
|
|
209
|
|
|
$filesystem = new Filesystem; |
210
|
|
|
|
211
|
|
|
collect($filesystem->allFiles(__DIR__.'/stubs/init/app/AuthRequests')) |
|
|
|
|
212
|
|
|
->each(function (SplFileInfo $file) use ($filesystem) { |
213
|
|
|
$filesystem->copy( |
214
|
|
|
$file->getPathname(), |
215
|
|
|
app_path('Http/Requests/Auth/'.Str::replaceLast('.stub', '.php', $file->getFilename())) |
216
|
|
|
); |
217
|
|
|
}); |
218
|
|
|
|
219
|
|
|
$this->components->info('Http/Requests/Auth classes scaffolding generated successfully.'); |
220
|
|
|
} |
221
|
|
|
|
222
|
|
|
protected function handleAppListenersPath() |
223
|
|
|
{ |
224
|
|
|
if (! is_dir($directory = app_path('Listeners'))) { |
225
|
|
|
mkdir($directory, 0755, true); |
226
|
|
|
} |
227
|
|
|
|
228
|
|
|
$filesystem = new Filesystem; |
229
|
|
|
|
230
|
|
|
collect($filesystem->allFiles(__DIR__.'/stubs/init/app/Listeners')) |
|
|
|
|
231
|
|
|
->each(function (SplFileInfo $file) use ($filesystem) { |
232
|
|
|
$filesystem->copy( |
233
|
|
|
$file->getPathname(), |
234
|
|
|
app_path('Listeners/'.Str::replaceLast('.stub', '.php', $file->getFilename())) |
235
|
|
|
); |
236
|
|
|
}); |
237
|
|
|
|
238
|
|
|
$this->components->info('Listener classes scaffolding generated successfully.'); |
239
|
|
|
} |
240
|
|
|
|
241
|
|
|
protected function handleAppModelsPath() |
242
|
|
|
{ |
243
|
|
|
if (! is_dir($directory = app_path('Models'))) { |
244
|
|
|
mkdir($directory, 0755, true); |
245
|
|
|
} |
246
|
|
|
|
247
|
|
|
$filesystem = new Filesystem; |
248
|
|
|
|
249
|
|
|
collect($filesystem->allFiles(__DIR__.'/stubs/init/app/Models')) |
|
|
|
|
250
|
|
|
->each(function (SplFileInfo $file) use ($filesystem) { |
251
|
|
|
$filesystem->copy( |
252
|
|
|
$file->getPathname(), |
253
|
|
|
app_path('Models/'.Str::replaceLast('.stub', '.php', $file->getFilename())) |
254
|
|
|
); |
255
|
|
|
}); |
256
|
|
|
|
257
|
|
|
$this->components->info('Models classes scaffolding generated successfully.'); |
258
|
|
|
} |
259
|
|
|
|
260
|
|
|
protected function handleAppModelsScopesPath() |
261
|
|
|
{ |
262
|
|
|
if (! is_dir($directory = app_path('Models/Scopes'))) { |
263
|
|
|
mkdir($directory, 0755, true); |
264
|
|
|
} |
265
|
|
|
|
266
|
|
|
$filesystem = new Filesystem; |
267
|
|
|
|
268
|
|
|
collect($filesystem->allFiles(__DIR__.'/stubs/init/app/ModelsScopes')) |
|
|
|
|
269
|
|
|
->each(function (SplFileInfo $file) use ($filesystem) { |
270
|
|
|
$filesystem->copy( |
271
|
|
|
$file->getPathname(), |
272
|
|
|
app_path('Models/Scopes/'.Str::replaceLast('.stub', '.php', $file->getFilename())) |
273
|
|
|
); |
274
|
|
|
}); |
275
|
|
|
|
276
|
|
|
$this->components->info('Models/Scopes classes scaffolding generated successfully.'); |
277
|
|
|
} |
278
|
|
|
|
279
|
|
|
protected function handleAppNotificationsPath() |
280
|
|
|
{ |
281
|
|
|
if (! is_dir($directory = app_path('Notifications'))) { |
282
|
|
|
mkdir($directory, 0755, true); |
283
|
|
|
} |
284
|
|
|
|
285
|
|
|
$filesystem = new Filesystem; |
286
|
|
|
|
287
|
|
|
collect($filesystem->allFiles(__DIR__.'/stubs/init/app/Notifications')) |
|
|
|
|
288
|
|
|
->each(function (SplFileInfo $file) use ($filesystem) { |
289
|
|
|
$filesystem->copy( |
290
|
|
|
$file->getPathname(), |
291
|
|
|
app_path('Notifications/'.Str::replaceLast('.stub', '.php', $file->getFilename())) |
292
|
|
|
); |
293
|
|
|
}); |
294
|
|
|
|
295
|
|
|
$this->components->info('Notification classes scaffolding generated successfully.'); |
296
|
|
|
} |
297
|
|
|
|
298
|
|
|
protected function handleAppProvidersPath() |
299
|
|
|
{ |
300
|
|
|
if (! is_dir($directory = app_path('Providers'))) { |
301
|
|
|
mkdir($directory, 0755, true); |
302
|
|
|
} |
303
|
|
|
|
304
|
|
|
$filesystem = new Filesystem; |
305
|
|
|
|
306
|
|
|
collect($filesystem->allFiles(__DIR__.'/stubs/init/app/Providers')) |
|
|
|
|
307
|
|
|
->each(function (SplFileInfo $file) use ($filesystem) { |
308
|
|
|
$filesystem->copy( |
309
|
|
|
$file->getPathname(), |
310
|
|
|
app_path('Providers/'.Str::replaceLast('.stub', '.php', $file->getFilename())) |
311
|
|
|
); |
312
|
|
|
}); |
313
|
|
|
|
314
|
|
|
$this->components->info('Provider classes scaffolding generated successfully.'); |
315
|
|
|
} |
316
|
|
|
|
317
|
|
|
protected function handleAppRepositoriesPath() |
318
|
|
|
{ |
319
|
|
|
if (! is_dir($directory = app_path('Repositories'))) { |
320
|
|
|
mkdir($directory, 0755, true); |
321
|
|
|
} |
322
|
|
|
|
323
|
|
|
$filesystem = new Filesystem; |
324
|
|
|
|
325
|
|
|
collect($filesystem->allFiles(__DIR__.'/stubs/init/app/Repositories')) |
|
|
|
|
326
|
|
|
->each(function (SplFileInfo $file) use ($filesystem) { |
327
|
|
|
$filesystem->copy( |
328
|
|
|
$file->getPathname(), |
329
|
|
|
app_path('Repositories/'.Str::replaceLast('.stub', '.php', $file->getFilename())) |
330
|
|
|
); |
331
|
|
|
}); |
332
|
|
|
|
333
|
|
|
$this->components->info('Repository classes scaffolding generated successfully.'); |
334
|
|
|
} |
335
|
|
|
|
336
|
|
|
protected function handleAppRulesPath() |
337
|
|
|
{ |
338
|
|
|
if (! is_dir($directory = app_path('Rules'))) { |
339
|
|
|
mkdir($directory, 0755, true); |
340
|
|
|
} |
341
|
|
|
|
342
|
|
|
$filesystem = new Filesystem; |
343
|
|
|
|
344
|
|
|
collect($filesystem->allFiles(__DIR__.'/stubs/init/app/Rules')) |
|
|
|
|
345
|
|
|
->each(function (SplFileInfo $file) use ($filesystem) { |
346
|
|
|
$filesystem->copy( |
347
|
|
|
$file->getPathname(), |
348
|
|
|
app_path('Rules/'.Str::replaceLast('.stub', '.php', $file->getFilename())) |
349
|
|
|
); |
350
|
|
|
}); |
351
|
|
|
|
352
|
|
|
$this->components->info('Rule classes scaffolding generated successfully.'); |
353
|
|
|
} |
354
|
|
|
|
355
|
|
|
protected function handleAppServicesPath() |
356
|
|
|
{ |
357
|
|
|
if (! is_dir($directory = app_path('Services'))) { |
358
|
|
|
mkdir($directory, 0755, true); |
359
|
|
|
} |
360
|
|
|
|
361
|
|
|
$filesystem = new Filesystem; |
362
|
|
|
|
363
|
|
|
collect($filesystem->allFiles(__DIR__.'/stubs/init/app/Services')) |
|
|
|
|
364
|
|
|
->each(function (SplFileInfo $file) use ($filesystem) { |
365
|
|
|
$filesystem->copy( |
366
|
|
|
$file->getPathname(), |
367
|
|
|
app_path('Services/'.Str::replaceLast('.stub', '.php', $file->getFilename())) |
368
|
|
|
); |
369
|
|
|
}); |
370
|
|
|
|
371
|
|
|
$this->components->info('Service classes scaffolding generated successfully.'); |
372
|
|
|
} |
373
|
|
|
|
374
|
|
|
protected function handleAppServicesAuthPath() |
375
|
|
|
{ |
376
|
|
|
if (! is_dir($directory = app_path('Services/Auth'))) { |
377
|
|
|
mkdir($directory, 0755, true); |
378
|
|
|
} |
379
|
|
|
|
380
|
|
|
$filesystem = new Filesystem; |
381
|
|
|
|
382
|
|
|
collect($filesystem->allFiles(__DIR__.'/stubs/init/app/AuthServices')) |
|
|
|
|
383
|
|
|
->each(function (SplFileInfo $file) use ($filesystem) { |
384
|
|
|
$filesystem->copy( |
385
|
|
|
$file->getPathname(), |
386
|
|
|
app_path('Services/Auth/'.Str::replaceLast('.stub', '.php', $file->getFilename())) |
387
|
|
|
); |
388
|
|
|
}); |
389
|
|
|
|
390
|
|
|
$this->components->info('Service/Auth classes scaffolding generated successfully.'); |
391
|
|
|
} |
392
|
|
|
|
393
|
|
|
protected function handleAppTraitsPath() |
394
|
|
|
{ |
395
|
|
|
if (! is_dir($directory = app_path('Traits'))) { |
396
|
|
|
mkdir($directory, 0755, true); |
397
|
|
|
} |
398
|
|
|
|
399
|
|
|
$filesystem = new Filesystem; |
400
|
|
|
|
401
|
|
|
collect($filesystem->allFiles(__DIR__.'/stubs/init/app/Traits')) |
|
|
|
|
402
|
|
|
->each(function (SplFileInfo $file) use ($filesystem) { |
403
|
|
|
$filesystem->copy( |
404
|
|
|
$file->getPathname(), |
405
|
|
|
app_path('Traits/'.Str::replaceLast('.stub', '.php', $file->getFilename())) |
406
|
|
|
); |
407
|
|
|
}); |
408
|
|
|
|
409
|
|
|
$this->components->info('Trait classes scaffolding generated successfully.'); |
410
|
|
|
} |
411
|
|
|
|
412
|
|
|
protected function handleConfigPath() |
413
|
|
|
{ |
414
|
|
|
if (! is_dir($directory = base_path('config'))) { |
415
|
|
|
mkdir($directory, 0755, true); |
416
|
|
|
} |
417
|
|
|
|
418
|
|
|
$filesystem = new Filesystem; |
419
|
|
|
|
420
|
|
|
collect($filesystem->allFiles(__DIR__.'/stubs/init/config')) |
|
|
|
|
421
|
|
|
->each(function (SplFileInfo $file) use ($filesystem) { |
422
|
|
|
$filesystem->copy( |
423
|
|
|
$file->getPathname(), |
424
|
|
|
base_path('config/'.Str::replaceLast('.stub', '.php', $file->getFilename())) |
425
|
|
|
); |
426
|
|
|
}); |
427
|
|
|
|
428
|
|
|
$this->components->info('config files scaffolding generated successfully.'); |
429
|
|
|
} |
430
|
|
|
|
431
|
|
|
protected function handleDatabasePath() |
432
|
|
|
{ |
433
|
|
|
if (! is_dir($directory = base_path('database/factories'))) { |
434
|
|
|
mkdir($directory, 0755, true); |
435
|
|
|
} |
436
|
|
|
|
437
|
|
|
if (! is_dir($directory = base_path('database/migrations'))) { |
438
|
|
|
mkdir($directory, 0755, true); |
439
|
|
|
} |
440
|
|
|
|
441
|
|
|
$filesystem = new Filesystem; |
442
|
|
|
|
443
|
|
|
collect($filesystem->allFiles(__DIR__.'/stubs/init/database/factories')) |
|
|
|
|
444
|
|
|
->each(function (SplFileInfo $file) use ($filesystem) { |
445
|
|
|
$filesystem->copy( |
446
|
|
|
$file->getPathname(), |
447
|
|
|
base_path('database/factories/'.Str::replaceLast('.stub', '.php', $file->getFilename())) |
448
|
|
|
); |
449
|
|
|
}); |
450
|
|
|
|
451
|
|
|
$this->components->info('database/factories files scaffolding generated successfully.'); |
452
|
|
|
|
453
|
|
|
collect($filesystem->allFiles(__DIR__.'/stubs/init/database/migrations')) |
454
|
|
|
->each(function (SplFileInfo $file) use ($filesystem) { |
455
|
|
|
$filesystem->copy( |
456
|
|
|
$file->getPathname(), |
457
|
|
|
base_path('database/migrations/'.Str::replaceLast('.stub', '.php', $file->getFilename())) |
458
|
|
|
); |
459
|
|
|
}); |
460
|
|
|
|
461
|
|
|
$this->components->info('database/migrations files scaffolding generated successfully.'); |
462
|
|
|
} |
463
|
|
|
|
464
|
|
|
protected function handleLangPath() |
465
|
|
|
{ |
466
|
|
|
if (! is_dir($directory = base_path('lang/en'))) { |
467
|
|
|
mkdir($directory, 0755, true); |
468
|
|
|
} |
469
|
|
|
|
470
|
|
|
$filesystem = new Filesystem; |
471
|
|
|
|
472
|
|
|
collect($filesystem->allFiles(__DIR__.'/stubs/init/lang/en')) |
|
|
|
|
473
|
|
|
->each(function (SplFileInfo $file) use ($filesystem) { |
474
|
|
|
$filesystem->copy( |
475
|
|
|
$file->getPathname(), |
476
|
|
|
base_path('lang/en/'.Str::replaceLast('.stub', '.php', $file->getFilename())) |
477
|
|
|
); |
478
|
|
|
}); |
479
|
|
|
|
480
|
|
|
$this->components->info('lang/en files scaffolding generated successfully.'); |
481
|
|
|
} |
482
|
|
|
|
483
|
|
|
protected function handleRoutesPath() |
484
|
|
|
{ |
485
|
|
|
|
486
|
|
|
if (! is_dir($directory = base_path('routes/app'))) { |
487
|
|
|
mkdir($directory, 0755, true); |
488
|
|
|
} |
489
|
|
|
|
490
|
|
|
$filesystem = new Filesystem; |
491
|
|
|
|
492
|
|
|
collect($filesystem->allFiles(__DIR__.'/stubs/init/routes/app')) |
|
|
|
|
493
|
|
|
->each(function (SplFileInfo $file) use ($filesystem) { |
494
|
|
|
$filesystem->copy( |
495
|
|
|
$file->getPathname(), |
496
|
|
|
base_path('routes/app/'.Str::replaceLast('.stub', '.php', $file->getFilename())) |
497
|
|
|
); |
498
|
|
|
}); |
499
|
|
|
|
500
|
|
|
$this->components->info('routes/app files scaffolding generated successfully.'); |
501
|
|
|
|
502
|
|
|
file_put_contents( |
503
|
|
|
base_path('routes/web.php'), |
504
|
|
|
file_get_contents(__DIR__.'/stubs/init/routes/web.stub'), |
505
|
|
|
FILE_APPEND |
506
|
|
|
); |
507
|
|
|
|
508
|
|
|
file_put_contents( |
509
|
|
|
base_path('routes/api.php'), |
510
|
|
|
file_get_contents(__DIR__.'/stubs/init/routes/api.stub'), |
511
|
|
|
FILE_APPEND |
512
|
|
|
); |
513
|
|
|
|
514
|
|
|
$this->components->info('routes scaffolding generated successfully.'); |
515
|
|
|
} |
516
|
|
|
|
517
|
|
|
protected function handleTestsPath() |
518
|
|
|
{ |
519
|
|
|
if (! is_dir($directory = base_path('tests/Feature'))) { |
520
|
|
|
mkdir($directory, 0755, true); |
521
|
|
|
} |
522
|
|
|
|
523
|
|
|
$filesystem = new Filesystem; |
524
|
|
|
|
525
|
|
|
collect($filesystem->allFiles(__DIR__.'/stubs/init/tests/Feature')) |
|
|
|
|
526
|
|
|
->each(function (SplFileInfo $file) use ($filesystem) { |
527
|
|
|
$filesystem->copy( |
528
|
|
|
$file->getPathname(), |
529
|
|
|
base_path('tests/Feature/'.Str::replaceLast('.stub', '.php', $file->getFilename())) |
530
|
|
|
); |
531
|
|
|
}); |
532
|
|
|
|
533
|
|
|
$this->components->info('tests/Feature files scaffolding generated successfully.'); |
534
|
|
|
} |
535
|
|
|
|
536
|
|
|
protected function handleResourcesPath() |
537
|
|
|
{ |
538
|
|
|
if (! is_dir($directory = base_path('resources/views/layouts'))) { |
539
|
|
|
mkdir($directory, 0755, true); |
540
|
|
|
} |
541
|
|
|
|
542
|
|
|
if (! is_dir($directory = base_path('resources/views/passwords'))) { |
543
|
|
|
mkdir($directory, 0755, true); |
544
|
|
|
} |
545
|
|
|
|
546
|
|
|
if (! is_dir($directory = base_path('resources/views/socialite'))) { |
547
|
|
|
mkdir($directory, 0755, true); |
548
|
|
|
} |
549
|
|
|
|
550
|
|
|
if (! is_dir($directory = base_path('resources/views/twofactor'))) { |
551
|
|
|
mkdir($directory, 0755, true); |
552
|
|
|
} |
553
|
|
|
|
554
|
|
|
$filesystem = new Filesystem; |
555
|
|
|
|
556
|
|
|
collect($filesystem->allFiles(__DIR__.'/stubs/init/resources/views/layouts')) |
|
|
|
|
557
|
|
|
->each(function (SplFileInfo $file) use ($filesystem) { |
558
|
|
|
$filesystem->copy( |
559
|
|
|
$file->getPathname(), |
560
|
|
|
base_path('resources/views/layouts/'.Str::replaceLast('.stub', '.php', $file->getFilename())) |
561
|
|
|
); |
562
|
|
|
}); |
563
|
|
|
|
564
|
|
|
$this->components->info('resources/views/layouts files scaffolding generated successfully.'); |
565
|
|
|
|
566
|
|
|
collect($filesystem->allFiles(__DIR__.'/stubs/init/resources/views/passwords')) |
567
|
|
|
->each(function (SplFileInfo $file) use ($filesystem) { |
568
|
|
|
$filesystem->copy( |
569
|
|
|
$file->getPathname(), |
570
|
|
|
base_path('resources/views/passwords/'.Str::replaceLast('.stub', '.php', $file->getFilename())) |
571
|
|
|
); |
572
|
|
|
}); |
573
|
|
|
|
574
|
|
|
$this->components->info('resources/views/passwords files scaffolding generated successfully.'); |
575
|
|
|
|
576
|
|
|
collect($filesystem->allFiles(__DIR__.'/stubs/init/resources/views/socialite')) |
577
|
|
|
->each(function (SplFileInfo $file) use ($filesystem) { |
578
|
|
|
$filesystem->copy( |
579
|
|
|
$file->getPathname(), |
580
|
|
|
base_path('resources/views/socialite/'.Str::replaceLast('.stub', '.php', $file->getFilename())) |
581
|
|
|
); |
582
|
|
|
}); |
583
|
|
|
|
584
|
|
|
$this->components->info('resources/views/socialite files scaffolding generated successfully.'); |
585
|
|
|
|
586
|
|
|
collect($filesystem->allFiles(__DIR__.'/stubs/init/resources/views/twofactor')) |
587
|
|
|
->each(function (SplFileInfo $file) use ($filesystem) { |
588
|
|
|
$filesystem->copy( |
589
|
|
|
$file->getPathname(), |
590
|
|
|
base_path('resources/views/twofactor/'.Str::replaceLast('.stub', '.php', $file->getFilename())) |
591
|
|
|
); |
592
|
|
|
}); |
593
|
|
|
|
594
|
|
|
$this->components->info('resources/views/twofactor files scaffolding generated successfully.'); |
595
|
|
|
} |
596
|
|
|
} |
597
|
|
|
|