Commit 5860e1b7 authored by Nicolas Widart's avatar Nicolas Widart

Fixing merge conflicts

parents 81f878ae 994a3656
<?php namespace Modules\Core\Composers;
use Modules\Core\Contracts\Authentication;
abstract class BaseSidebarViewComposer
{
/**
* @var Authentication
*/
protected $auth;
public function __construct(Authentication $auth)
{
$this->auth = $auth;
}
}
......@@ -8,68 +8,68 @@ use Modules\User\Repositories\UserRepository;
class InstallCommand extends Command
{
/**
* The console command name.
*
* @var string
*/
protected $name = 'platform:install';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Install the Platform CMS';
/**
* @var UserRepository
*/
private $user;
/**
* @var Filesystem
*/
private $finder;
/**
* Create a new command instance.
*
* @param UserRepository $user
* @param Filesystem $finder
* @return \Modules\Core\Console\InstallCommand
*/
public function __construct($user, Filesystem $finder)
{
parent::__construct();
$this->user = $user;
$this->finder = $finder;
}
/**
* Execute the actions
*
* @return mixed
*/
public function fire()
{
$this->info('Starting the installation process...');
$this->configureDatabase();
/**
* The console command name.
*
* @var string
*/
protected $name = 'platform:install';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Install the Platform CMS';
/**
* @var UserRepository
*/
private $user;
/**
* @var Filesystem
*/
private $finder;
/**
* Create a new command instance.
*
* @param UserRepository $user
* @param Filesystem $finder
* @return \Modules\Core\Console\InstallCommand
*/
public function __construct($user, Filesystem $finder)
{
parent::__construct();
$this->user = $user;
$this->finder = $finder;
}
/**
* Execute the actions
*
* @return mixed
*/
public function fire()
{
$this->info('Starting the installation process...');
$this->configureDatabase();
if ($this->confirm('Do you wish to init sentinel and create its first user? [yes|no]')) {
$this->runUserCommands();
}
$this->runMigrations();
$this->runMigrations();
$this->publishAssets();
$this->publishAssets();
$this->blockMessage(
'Success!',
'Platform ready! You can now login with your username and password at /backend'
);
}
$this->blockMessage(
'Success!',
'Platform ready! You can now login with your username and password at /backend'
);
}
/**
*
......@@ -83,140 +83,133 @@ class InstallCommand extends Command
$this->info('User commands done.');
}
/**
* Create the first user that'll have admin access
*/
private function createFirstUser()
{
$this->line('Creating an Admin user account...');
$firstname = $this->ask('Enter your first name');
$lastname = $this->ask('Enter your last name');
$email = $this->ask('Enter your email address');
$password = $this->secret('Enter a password');
$userInfo = [
'first_name' => $firstname,
'last_name' => $lastname,
'email' => $email,
'password' => Hash::make($password),
];
$this->user->createWithRoles($userInfo, ['admin']);
$this->info('Admin account created!');
}
/**
* Create the first user that'll have admin access
*/
private function createFirstUser()
{
$this->line('Creating an Admin user account...');
$firstname = $this->ask('Enter your first name');
$lastname = $this->ask('Enter your last name');
$email = $this->ask('Enter your email address');
$password = $this->secret('Enter a password');
$userInfo = [
'first_name' => $firstname,
'last_name' => $lastname,
'email' => $email,
'password' => Hash::make($password),
];
$this->user->createWithRoles($userInfo, ['admin']);
$this->info('Admin account created!');
}
/**
* Run migrations specific to Sentinel
*/
*/
private function runSentinelMigrations()
{
$this->call('migrate', ['--package' => 'cartalyst/sentinel']);
}
/**
* Run the migrations
*/
private function runMigrations()
{
$this->call('module:migrate', ['module' => 'Setting']);
/**
* Run the migrations
*/
private function runMigrations()
{
$this->call('module:migrate', ['module' => 'Setting']);
$this->info('Application migrated!');
}
$this->info('Application migrated!');
}
private function runUserSeeds()
{
$this->call('module:seed', ['module' => 'User']);
}
/**
* Run the seeds
*/
private function runSeeds()
{
$this->info('Application seeded!');
}
/**
* Symfony style block messages
* @param $title
* @param $message
* @param string $style
*/
protected function blockMessage($title, $message, $style = 'info')
{
$formatter = $this->getHelperSet()->get('formatter');
$errorMessages = [$title, $message];
$formattedBlock = $formatter->formatBlock($errorMessages, $style, true);
$this->line($formattedBlock);
}
/**
* Publish the CMS assets
*/
private function publishAssets()
{
$this->call('module:publish', ['module' => 'Core']);
}
/**
* Configuring the database information
*/
private function configureDatabase()
{
// Ask for credentials
$databaseName = $this->ask('Enter your database name');
$databaseUsername = $this->ask('Enter your database username');
$databasePassword = $this->secret('Enter your database password');
$this->setLaravelConfiguration($databaseName, $databaseUsername, $databasePassword);
$this->configureEnvironmentFile($databaseName, $databaseUsername, $databasePassword);
}
/**
* Writing the environment file
* @param $databaseName
* @param $databaseUsername
* @param $databasePassword
*/
private function configureEnvironmentFile($databaseName, $databaseUsername, $databasePassword)
{
Dotenv::makeMutable();
$environmentFile = $this->finder->get('.env.example');
$search = [
"DB_USERNAME=homestead",
"DB_PASSWORD=homestead"
];
/**
* Symfony style block messages
* @param $title
* @param $message
* @param string $style
*/
protected function blockMessage($title, $message, $style = 'info')
{
$formatter = $this->getHelperSet()->get('formatter');
$errorMessages = [$title, $message];
$formattedBlock = $formatter->formatBlock($errorMessages, $style, true);
$this->line($formattedBlock);
}
/**
* Publish the CMS assets
*/
private function publishAssets()
{
$this->call('module:publish', ['module' => 'Core']);
}
/**
* Configuring the database information
*/
private function configureDatabase()
{
// Ask for credentials
$databaseName = $this->ask('Enter your database name');
$databaseUsername = $this->ask('Enter your database username');
$databasePassword = $this->secret('Enter your database password');
$this->setLaravelConfiguration($databaseName, $databaseUsername, $databasePassword);
$this->configureEnvironmentFile($databaseName, $databaseUsername, $databasePassword);
}
/**
* Writing the environment file
* @param $databaseName
* @param $databaseUsername
* @param $databasePassword
*/
private function configureEnvironmentFile($databaseName, $databaseUsername, $databasePassword)
{
Dotenv::makeMutable();
$environmentFile = $this->finder->get('.env.example');
$search = [
"DB_USERNAME=homestead",
"DB_PASSWORD=homestead"
];
$replace = [
"DB_USERNAME=$databaseUsername",
"DB_PASSWORD=$databasePassword" . PHP_EOL
];
$newEnvironmentFile = str_replace($search, $replace, $environmentFile);
$newEnvironmentFile .= "DB_NAME=$databaseName";
// Write the new environment file
$this->finder->put('.env', $newEnvironmentFile);
// Delete the old environment file
$this->finder->delete('env.example');
$this->info('Environment file written');
Dotenv::makeImmutable();
}
/**
* Set DB credentials to laravel config
* @param $databaseName
* @param $databaseUsername
* @param $databasePassword
*/
private function setLaravelConfiguration($databaseName, $databaseUsername, $databasePassword)
{
$this->laravel['config']['database.connections.mysql.database'] = $databaseName;
$this->laravel['config']['database.connections.mysql.username'] = $databaseUsername;
$this->laravel['config']['database.connections.mysql.password'] = $databasePassword;
}
$replace = [
"DB_USERNAME=$databaseUsername",
"DB_PASSWORD=$databasePassword" . PHP_EOL
];
$newEnvironmentFile = str_replace($search, $replace, $environmentFile);
$newEnvironmentFile .= "DB_NAME=$databaseName";
// Write the new environment file
$this->finder->put('.env', $newEnvironmentFile);
// Delete the old environment file
$this->finder->delete('env.example');
$this->info('Environment file written');
Dotenv::makeImmutable();
}
/**
* Set DB credentials to laravel config
* @param $databaseName
* @param $databaseUsername
* @param $databasePassword
*/
private function setLaravelConfiguration($databaseName, $databaseUsername, $databasePassword)
{
$this->laravel['config']['database.connections.mysql.database'] = $databaseName;
$this->laravel['config']['database.connections.mysql.username'] = $databaseUsername;
$this->laravel['config']['database.connections.mysql.password'] = $databasePassword;
}
}
......@@ -61,4 +61,11 @@ interface Authentication
* @return bool
*/
public function completeResetPassword($user, $code, $password);
/**
* Determines if the current user has access to given permission
* @param $permission
* @return bool
*/
public function hasAccess($permission);
}
......@@ -6,26 +6,32 @@
<?php $items = \Modules\Core\Navigation\NavigationOrdener::order($items); ?>
<?php foreach($items as $i => $item): ?>
<?php if (is_object($item)): ?>
<li class="treeview {{ $item[0]['request'] ? 'active' : ''}}">
<a href="#">
<i class="{{ $item[0]['icon-class'] }}"></i> <span>{{ $item[0]['title'] }}</span>
<i class="fa fa-angle-left pull-right"></i>
</a>
<?php $item->shift(); ?>
<ul class="treeview-menu">
<?php foreach($item as $subItem): ?>
<li class="{{ Request::is($subItem['request']) ? 'active' : ''}}">
<a href="{{ URL::route($subItem['route']) }}"><i class="{{$subItem['icon-class']}}"></i> {{ $subItem['title'] }}</a>
</li>
<?php endforeach; ?>
</ul>
</li>
<?php if ($item[0]['permission']): ?>
<li class="treeview {{ $item[0]['request'] ? 'active' : ''}}">
<a href="#">
<i class="{{ $item[0]['icon-class'] }}"></i> <span>{{ $item[0]['title'] }}</span>
<i class="fa fa-angle-left pull-right"></i>
</a>
<?php $item->shift(); ?>
<ul class="treeview-menu">
<?php foreach($item as $subItem): ?>
<?php if ($subItem['permission']): ?>
<li class="{{ Request::is($subItem['request']) ? 'active' : ''}}">
<a href="{{ URL::route($subItem['route']) }}"><i class="{{$subItem['icon-class']}}"></i> {{ $subItem['title'] }}</a>
</li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
</li>
<?php endif; ?>
<?php else: ?>
<li class="{{ Request::is($item['request']) ? 'active' : ''}}">
<a href="{{ URL::route($item['route']) }}">
<i class="{{ $item['icon-class'] }}"></i> <span>{{ $item['title'] }}</span>
</a>
</li>
<?php if ($item['permission']): ?>
<li class="{{ Request::is($item['request']) ? 'active' : ''}}">
<a href="{{ URL::route($item['route']) }}">
<i class="{{ $item['icon-class'] }}"></i> <span>{{ $item['title'] }}</span>
</a>
</li>
<?php endif; ?>
<?php endif; ?>
<?php endforeach; ?>
</ul>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment