1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Some of logic is used from jeroennoten/Laravel-AdminLTE Many thanks to the maintainers |
4
|
|
|
* you can checkout the package from here: https://github.com/jeroennoten/Laravel-AdminLTE |
5
|
|
|
*/ |
6
|
|
|
|
7
|
|
|
namespace Aminetiyal\LaravelTemplate\Commands; |
8
|
|
|
|
9
|
|
|
use Illuminate\Console\Command; |
10
|
|
|
use Illuminate\Support\Facades\File; |
11
|
|
|
|
12
|
|
|
class TemplateInstall extends Command |
13
|
|
|
{ |
14
|
|
|
protected $signature = 'template:install' . |
15
|
|
|
'{--auth : Update Auth views}' . |
16
|
|
|
'{--home : Update Home view}'; |
17
|
|
|
|
18
|
|
|
|
19
|
|
|
protected $description = 'Install template package'; |
20
|
|
|
|
21
|
|
|
protected $authViews = [ |
22
|
|
|
'views/auth/login.blade.php' => '@extends(\'template::lte.login\')', |
23
|
|
|
'views/auth/register.blade.php' => '@extends(\'template::lte.register\')', |
24
|
|
|
'views/auth/verify.blade.php' => '@extends(\'template::lte.verify\')', |
25
|
|
|
'views/auth/passwords/confirm.blade.php' => '@extends(\'template::lte.passwords.confirm\')', |
26
|
|
|
'views/auth/passwords/email.blade.php' => '@extends(\'template::lte.passwords.email\')', |
27
|
|
|
'views/auth/passwords/reset.blade.php' => '@extends(\'template::lte.passwords.reset\')', |
28
|
|
|
]; |
29
|
|
|
|
30
|
|
|
protected $homeView = 'views/home.blade.php'; |
31
|
|
|
|
32
|
|
|
public function __construct() |
33
|
|
|
{ |
34
|
|
|
parent::__construct(); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
public function handle() |
38
|
|
|
{ |
39
|
|
|
if ($this->option('home')) { |
40
|
|
|
$this->exportHomeView(); |
41
|
|
|
} |
42
|
|
|
if ($this->option('auth')) { |
43
|
|
|
$this->exportAuthViews(); |
44
|
|
|
} |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
protected function exportHomeView() |
48
|
|
|
{ |
49
|
|
|
if (!$this->confirm('Install Home view?')) { |
50
|
|
|
return; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
$content = '@extends(\'template::lte.main\')' . PHP_EOL . PHP_EOL . |
54
|
|
|
'@section(\'pageTitle\', \'Home\')' . PHP_EOL . PHP_EOL . |
55
|
|
|
'@section(\'content\')' . PHP_EOL . |
56
|
|
|
' {{-- Content Here --}}' . PHP_EOL . |
57
|
|
|
'@endsection'; |
58
|
|
|
|
59
|
|
|
file_put_contents(resource_path($this->homeView), $content); |
60
|
|
|
|
61
|
|
|
|
62
|
|
|
$this->comment('Home view updated successfully.'); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
protected function exportAuthViews() |
66
|
|
|
{ |
67
|
|
|
if (!$this->confirm('Install Template authentication views?')) { |
68
|
|
|
return; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
// create auth directory if not exists |
72
|
|
|
if (!File::isDirectory(resource_path('/views/auth'))) { |
73
|
|
|
File::makeDirectory(resource_path('views/auth'), 0755, true); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
foreach ($this->authViews as $file => $content) { |
77
|
|
|
file_put_contents(resource_path($file), $content); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
$this->comment('Authentication views updated successfully.'); |
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
|