rbrecruiter/app/Console/Commands/SetEnv.php
Miguel Nogueira 4eb115d165 Revert "Apply fixes from StyleCI (pull request #6)"
This reverts pull request #6.

> This pull request applies code style fixes from an analysis carried out by [StyleCI](https://bitbucket.styleci.io).
> 
> For more information, click [here](https://bitbucket.styleci.io/analyses/a2Jl7D).
2020-10-21 00:29:50 +00:00

57 lines
1.1 KiB
PHP

<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use GeoSot\EnvEditor\Facades\EnvEditor;
class SetEnv extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'environment:modify {key : Key name} {value : New value}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Permanently modifies an environment variable on the .env file for later use.';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
* @return mixed
*/
public function handle()
{
$path = base_path('/.env');
$key = $this->argument('key');
$value = $this->argument('value');
if (file_exists($path))
{
EnvEditor::editKey($key, $value);
}
else
{
$this->error('Cannot update a file that doesn\'t exist! Please create .env first.');
return false;
}
}
}