Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup modifications #2159

Merged
merged 2 commits into from
Oct 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 42 additions & 1 deletion app/Http/Controllers/SetupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,20 @@ class SetupController extends Controller
'log' => 'Log (Testing)',
];

/**
* Array of queue drivers.
*
* @var string[]
*/
protected $queueDrivers = [
'null' => 'None',
'sync' => 'Synchronous',
'database' => 'Database',
'beanstalkd' => 'Beanstalk',
'sqs' => 'Amazon SQS',
'redis' => 'Redis',
];

/**
* Array of step1 rules.
*
Expand Down Expand Up @@ -95,6 +109,7 @@ public function __construct()
$this->rulesStep1 = [
'env.cache_driver' => 'required|in:'.implode(',', array_keys($this->cacheDrivers)),
'env.session_driver' => 'required|in:'.implode(',', array_keys($this->cacheDrivers)),
'env.queue_driver' => 'required|in:'.implode(',', array_keys($this->queueDrivers)),
'env.mail_driver' => 'required|in:'.implode(',', array_keys($this->mailDrivers)),
];

Expand Down Expand Up @@ -132,12 +147,38 @@ public function getIndex()
}
}

// Since .env may already be configured, we should show that data!
$cacheConfig = [
'driver' => Config::get('cache.default'),
];

$sessionConfig = [
'driver' => Config::get('session.driver'),
];

$queueConfig = [
'driver' => Config::get('queue.default'),
];

$mailConfig = [
'driver' => Config::get('mail.driver'),
'host' => Config::get('mail.host'),
'from' => Config::get('mail.from'),
'username' => Config::get('mail.username'),
'password' => Config::get('mail.password'),
];

return View::make('setup.index')
->withPageTitle(trans('setup.setup'))
->withCacheDrivers($this->cacheDrivers)
->withQueueDrivers($this->queueDrivers)
->withMailDrivers($this->mailDrivers)
->withUserLanguage($userLanguage)
->withAppUrl(Request::root());
->withAppUrl(Request::root())
->withCacheConfig($cacheConfig)
->withSessionConfig($sessionConfig)
->withQueueConfig($queueConfig)
->withMailConfig($mailConfig);
}

/**
Expand Down
1 change: 1 addition & 0 deletions resources/lang/en/forms.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
'site_locale' => 'Select your language',
'enable_google2fa' => 'Enable Google Two Factor Authentication',
'cache_driver' => 'Cache Driver',
'queue_driver' => 'Queue Driver',
'session_driver' => 'Session Driver',
'mail_driver' => 'Mail Driver',
'mail_host' => 'Mail Host',
Expand Down
71 changes: 44 additions & 27 deletions resources/views/setup/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,35 +31,52 @@
<div class="step block-1">
<fieldset>
<div class="form-group">
<label>{{ trans('forms.setup.cache_driver') }}</label>
<select name="env[cache_driver]" class="form-control" required>
<option disabled>{{ trans('forms.setup.cache_driver') }}</option>
@foreach($cache_drivers as $driver => $driverName)
<option value="{{ $driver }}" {{ Binput::old('env.cache_driver') == $driver || $driver === "file" ? "selected" : null }}>{{ $driverName }}</option>
@endforeach
</select>
@if($errors->has('env.cache_driver'))
<span class="text-danger">{{ $errors->first('env.cache_driver') }}</span>
@endif
</div>
<div class="form-group">
<label>{{ trans('forms.setup.session_driver') }}</label>
<select name="env[session_driver]" class="form-control" required>
<option disabled>{{ trans('forms.setup.session_driver') }}</option>
@foreach($cache_drivers as $driver => $driverName)
<option value="{{ $driver }}" {{ Binput::old('env.session_driver') == $driver || $driver === "file" ? "selected" : null }}>{{ $driverName }}</option>
@endforeach
</select>
@if($errors->has('env.session_driver'))
<span class="text-danger">{{ $errors->first('env.session_driver') }}</span>
@endif
<div class="row">
<div class="col-xs-4">
<label>{{ trans('forms.setup.cache_driver') }}</label>
<select name="env[cache_driver]" class="form-control" required>
<option disabled>{{ trans('forms.setup.cache_driver') }}</option>
@foreach($cache_drivers as $driver => $driverName)
<option value="{{ $driver }}" {{ Binput::old('env.cache_driver', $cache_config['driver']) == $driver ? "selected" : null }}>{{ $driverName }}</option>
@endforeach
</select>
@if($errors->has('env.cache_driver'))
<span class="text-danger">{{ $errors->first('env.cache_driver') }}</span>
@endif
</div>
<div class="col-xs-4">
<label>{{ trans('forms.setup.queue_driver') }}</label>
<select name="env[queue_driver]" class="form-control" required>
<option disabled>{{ trans('forms.setup.queue_driver') }}</option>
@foreach($queue_drivers as $driver => $driverName)
<option value="{{ $driver }}" {{ Binput::old('env.queue_driver', $queue_config['driver']) == $driver ? "selected" : null }}>{{ $driverName }}</option>
@endforeach
</select>
@if($errors->has('env.queue_driver'))
<span class="text-danger">{{ $errors->first('env.queue_driver') }}</span>
@endif
</div>
<div class="col-xs-4">
<label>{{ trans('forms.setup.session_driver') }}</label>
<select name="env[session_driver]" class="form-control" required>
<option disabled>{{ trans('forms.setup.session_driver') }}</option>
@foreach($cache_drivers as $driver => $driverName)
<option value="{{ $driver }}" {{ Binput::old('env.session_driver', $session_config['driver']) == $driver ? "selected" : null }}>{{ $driverName }}</option>
@endforeach
</select>
@if($errors->has('env.session_driver'))
<span class="text-danger">{{ $errors->first('env.session_driver') }}</span>
@endif
</div>
</div>
</div>
<hr>
<div class="form-group">
<label>{{ trans('forms.setup.mail_driver') }}</label>
<select name="env[mail_driver]" class="form-control" required>
<option disabled>{{ trans('forms.setup.mail_driver') }}</option>
@foreach($mail_drivers as $driver => $driverName)
<option value="{{ $driver }}" {{ Binput::old('env.mail_driver') == $driver || $driver === "log" ? "selected" : null }}>{{ $driverName }}</option>
<option value="{{ $driver }}" {{ Binput::old('env.mail_driver', $mail_config['driver']) == $driver ? "selected" : null }}>{{ $driverName }}</option>
@endforeach
</select>
@if($errors->has('env.mail_driver'))
Expand All @@ -68,28 +85,28 @@
</div>
<div class="form-group">
<label>{{ trans('forms.setup.mail_host') }} (optional)</label>
<input type="text" class="form-control" name="env[mail_host]" value="{{ Binput::old('env.mail_host') }}">
<input type="text" class="form-control" name="env[mail_host]" value="{{ Binput::old('env.mail_host', $mail_config['host']) }}">
@if($errors->has('env.mail_host'))
<span class="text-danger">{{ $errors->first('env.mail_host') }}</span>
@endif
</div>
<div class="form-group">
<label>{{ trans('forms.setup.mail_address') }}</label>
<input type="text" class="form-control" name="env[mail_address]" value="{{ Binput::old('env.mail_address') }}" placeholder="notifications@alt-three.com">
<input type="text" class="form-control" name="env[mail_address]" value="{{ Binput::old('env.mail_address', $mail_config['from']['address']) }}" placeholder="notifications@alt-three.com">
@if($errors->has('env.mail_address'))
<span class="text-danger">{{ $errors->first('env.mail_address') }}</span>
@endif
</div>
<div class="form-group">
<label>{{ trans('forms.setup.mail_username') }}</label>
<input type="text" class="form-control" name="env[mail_username]" value="{{ Binput::old('env.mail_username') }}">
<input type="text" class="form-control" name="env[mail_username]" value="{{ Binput::old('env.mail_username', $mail_config['username']) }}">
@if($errors->has('env.mail_username'))
<span class="text-danger">{{ $errors->first('env.mail_username') }}</span>
@endif
</div>
<div class="form-group">
<label>{{ trans('forms.setup.mail_password') }}</label>
<input type="text" class="form-control" name="env[mail_password]" value="{{ Binput::old('env.mail_password') }}" autocomplete="off">
<input type="password" class="form-control" name="env[mail_password]" value="{{ Binput::old('env.mail_password', $mail_config['password']) }}" autocomplete="off">
@if($errors->has('env.mail_password'))
<span class="text-danger">{{ $errors->first('env.mail_password') }}</span>
@endif
Expand Down