FEATURE #1523: add subpages for content

This commit is contained in:
Michal Kváček
2016-03-31 21:12:54 +02:00
parent acc7541ab9
commit e789b02a93
10 changed files with 192 additions and 24 deletions
+65
View File
@@ -0,0 +1,65 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
class SetupDatabase extends Command
{
/**
* The name and signature of the console command.
* @var string
*/
protected $signature = 'db:setup {host} {user} {password} {database}';
/**
* The console command description.
* @var string
*/
protected $description = 'Setup database credentials';
/**
* Create a new command instance.
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
* @return mixed
*/
public function handle()
{
echo "zpracovavam";
$host = $this->argument('host');
$user = $this->argument('user');
$password = $this->argument('password');
$database = $this->argument('database');
// try to connect with this settings
// @todo add credentials verification
// if pass, proceed to creating .env file
$parameters = [
'DB_HOST' => $host,
'DB_USERNAME' => $user,
'DB_PASSWORD' => $password,
'DB_DATABASE' => $database
];
$envPath = base_path('.env');
$env = file_get_contents($envPath);
if (!file_exists($envPath))
$env = file_get_contents($envPath.'.example');
foreach ($parameters as $parameter => $value) {
$env = preg_replace('/'.$parameter.'=(.*)/i', $parameter.'='.$value, $env);
}
file_put_contents($envPath, $env);
}
}