1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Bmatovu\MultiAuth\Console\Traits; |
4
|
|
|
|
5
|
|
|
use Illuminate\Filesystem\Filesystem; |
6
|
|
|
use Illuminate\Support\Str; |
7
|
|
|
|
8
|
|
|
trait InstallsInertiaVueStack |
9
|
|
|
{ |
10
|
|
|
/** |
11
|
|
|
* Install the InertiaVue Breeze stack. |
12
|
|
|
* |
13
|
|
|
* @return null|int |
14
|
|
|
*/ |
15
|
1 |
|
protected function installInertiaVueStack() |
16
|
|
|
{ |
17
|
1 |
|
$fs = new Filesystem; |
18
|
1 |
|
$guard = $this->argument('guard'); |
|
|
|
|
19
|
1 |
|
$pluralClass = Str::plural(Str::studly($guard)); |
20
|
1 |
|
$singularSlug = Str::singular(Str::slug($guard)); |
21
|
1 |
|
$singularClass = Str::singular(Str::studly($guard)); |
22
|
|
|
|
23
|
|
|
// Module... |
24
|
1 |
|
$fs->ensureDirectoryExists(app_path("Modules/{$pluralClass}")); |
25
|
1 |
|
$fs->copyDirectory(__DIR__ . '/../../../.stubs/inertia/src', app_path("Modules/{$pluralClass}")); |
26
|
|
|
|
27
|
|
|
// Views... |
28
|
1 |
|
$fs->ensureDirectoryExists(resource_path("views/{$singularSlug}")); |
29
|
1 |
|
$fs->copyDirectory(__DIR__ . '/../../../.stubs/vue/resources/js', resource_path("js/{$pluralClass}")); |
30
|
|
|
|
31
|
1 |
|
$fs->ensureDirectoryExists(resource_path("views/{$singularSlug}")); |
32
|
1 |
|
$fs->copyDirectory(__DIR__ . '/../../../.stubs/vue/resources/views', resource_path("views/{$singularSlug}")); |
33
|
|
|
|
34
|
|
|
// Tests... |
35
|
1 |
|
$fs->ensureDirectoryExists(base_path("tests/Feature/{$pluralClass}")); |
36
|
1 |
|
if ($this->option('pest')) { |
|
|
|
|
37
|
|
|
$fs->copyDirectory(__DIR__ . '/../../../.stubs/inertia/pest-tests/Feature', base_path("tests/Feature/{$pluralClass}")); |
38
|
|
|
} else { |
39
|
1 |
|
$fs->copyDirectory(__DIR__ . '/../../../.stubs/inertia/tests/Feature', base_path("tests/Feature/{$pluralClass}")); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
// Conclude... |
43
|
1 |
|
$this->info("{$singularClass} guard successfully setup."); |
|
|
|
|
44
|
|
|
|
45
|
1 |
|
$serviceProvider = "App\\Modules\\{$pluralClass}\\{$singularClass}ServiceProvider::class"; |
46
|
|
|
|
47
|
1 |
|
$this->info("\nRegister `{$serviceProvider}` in `config/app.php`"); |
48
|
|
|
} |
49
|
|
|
} |
50
|
|
|
|