|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Larrock\Core\Commands; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Console\Command; |
|
6
|
|
|
|
|
7
|
|
|
class LarrockUpdateEnvCommand extends Command |
|
8
|
|
|
{ |
|
9
|
|
|
/** |
|
10
|
|
|
* The name and signature of the console command. |
|
11
|
|
|
* |
|
12
|
|
|
* @var string |
|
13
|
|
|
*/ |
|
14
|
|
|
protected $signature = 'larrock:updateEnv'; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* The console command description. |
|
18
|
|
|
* |
|
19
|
|
|
* @var string |
|
20
|
|
|
*/ |
|
21
|
|
|
protected $description = 'Update Laravel .env to Larrock'; |
|
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 mixed |
|
37
|
|
|
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException |
|
38
|
|
|
*/ |
|
39
|
|
|
public function handle() |
|
40
|
|
|
{ |
|
41
|
|
|
$this->line('=== Check Laravel .env ==='); |
|
42
|
|
|
|
|
43
|
|
|
if( !env('LARROCK VARS')){ |
|
44
|
|
|
$this->info('=== Add LARROCK vars ==='); |
|
45
|
|
|
$current_env = \File::get(base_path('.env')); |
|
46
|
|
|
\File::put(base_path('.env'), $current_env ."\n\nLARROCK VARS=PLACED"); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
if( !env('MAIL_TEMPLATE_ADDRESS')){ |
|
50
|
|
|
$current_env = \File::get(base_path('.env')); |
|
51
|
|
|
\File::put(base_path('.env'), $current_env ."\nMAIL_TEMPLATE_ADDRESS='company address'"); |
|
52
|
|
|
$this->info('MAIL_FROM_ADDRESS not found. Add "company address"'); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
if( !env('MAIL_TEMPLATE_PHONE')){ |
|
56
|
|
|
$current_env = \File::get(base_path('.env')); |
|
57
|
|
|
\File::put(base_path('.env'), $current_env ."\nMAIL_TEMPLATE_PHONE=company phone"); |
|
58
|
|
|
$this->info('MAIL_TEMPLATE_PHONE not found. Add "company phone"'); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
if( !env('MAIL_TEMPLATE_MAIL')){ |
|
62
|
|
|
$current_env = \File::get(base_path('.env')); |
|
63
|
|
|
\File::put(base_path('.env'), $current_env ."\[email protected]"); |
|
64
|
|
|
$this->info('MAIL_TEMPLATE_MAIL not found. Add "[email protected]"'); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
if( !env('MAIL_FROM_ADDRESS')){ |
|
68
|
|
|
$current_env = \File::get(base_path('.env')); |
|
69
|
|
|
\File::put(base_path('.env'), $current_env ."\[email protected]"); |
|
70
|
|
|
$this->info('MAIL_FROM_ADDRESS not found. Add "[email protected]"'); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
if( !env('MAIL_TO_ADMIN')){ |
|
74
|
|
|
$current_env = \File::get(base_path('.env')); |
|
75
|
|
|
\File::put(base_path('.env'), $current_env ."\[email protected]"); |
|
76
|
|
|
$this->info('MAIL_TO_ADMIN not found. Add "[email protected]"'); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
if( !env('MAIL_FROM_NAME')){ |
|
80
|
|
|
$current_env = \File::get(base_path('.env')); |
|
81
|
|
|
\File::put(base_path('.env'), $current_env ."\nMAIL_FROM_NAME='LARROCK'"); |
|
82
|
|
|
$this->info('MAIL_FROM_NAME not found. Add "LARROCK"'); |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
if( !env('SITE_NAME')){ |
|
86
|
|
|
$current_env = \File::get(base_path('.env')); |
|
87
|
|
|
\File::put(base_path('.env'), $current_env ."\nSITE_NAME='LARROCK'"); |
|
88
|
|
|
$this->info('SITE_NAME not found. Add "LARROCK"'); |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
if( !env('MAIL_STOP')){ |
|
92
|
|
|
$current_env = \File::get(base_path('.env')); |
|
93
|
|
|
\File::put(base_path('.env'), $current_env ."\nMAIL_STOP=false"); |
|
94
|
|
|
$this->info('MAIL_STOP not found. Add "false"'); |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
$this->info('.env vars currently installed'); |
|
98
|
|
|
} |
|
99
|
|
|
} |
Adding a
@returnannotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.