@extends('layouts.installer')

@section('content')
    <div class="container">
        <div class="row justify-content-center align-content-center mt-5">
            <div class="col-md-6">
                <div class="card">
                    <div class="card-header" style="background: #d9dce2;">
                        <h1 class="h5 text-center m-0 card-title">Configure Database</h1>
                    </div>
                    <form action="{{ route('install.saveEnvironment') }}" method="post">
                        @csrf
                        <div class="card-body px-md-5">
                            @if ($errors->any())
                                <div class="alert alert-danger" role="alert">
                                    {{ $errors->first() }}
                                </div>
                            @endif
                            <div class="form-group">
                                <label for="database_hostname">Database Host</label>
                                <input type="text" class="form-control {{ $errors->has('database_hostname') ? ' is-invalid ' : '' }}" id="database_hostname" name="database_hostname" value="localhost" placeholder="127.0.0.1 / localhost">

                                @if ($errors->has('database_hostname'))
                                    <div class="invalid-feedback">{{ $errors->first('database_hostname') }}</div>
                                @endif
                            </div>
                            <div class="form-group">
                                <label for="database_port">Database Port</label>
                                <input type="text" class="form-control {{ $errors->has('database_port') ? ' is-invalid ' : '' }}" id="database_port" name="database_port" value="3306" placeholder="3306">

                                @if ($errors->has('database_port'))
                                    <div class="invalid-feedback">{{ $errors->first('database_port') }}</div>
                                @endif
                            </div>
                            <div class="form-group">
                                <label for="database_name">Database Name</label>
                                <input type="text" class="form-control {{ $errors->has('database_name') ? ' is-invalid ' : '' }}" id="database_name" name="database_name" value="{{ old('database_name') }}" placeholder="database_name">

                                @if ($errors->has('database_name'))
                                    <div class="invalid-feedback">{{ $errors->first('database_name') }}</div>
                                @endif
                            </div>
                            <div class="form-group">
                                <label for="database_username">Database Username</label>
                                <input type="text" class="form-control {{ $errors->has('database_username') ? ' is-invalid ' : '' }}" id="database_username" name="database_username" value="{{ old('database_username') }}" placeholder="database_username">

                                @if ($errors->has('database_username'))
                                    <div class="invalid-feedback">{{ $errors->first('database_username') }}</div>
                                @endif
                            </div>
                            <div class="form-group">
                                <label for="database_password">Database Password</label>
                                <input type="password" class="form-control {{ $errors->has('database_password') ? ' is-invalid ' : '' }}" id="database_password" name="database_password" value="{{ old('database_password') }}" placeholder="password">

                                @if ($errors->has('database_password'))
                                    <div class="invalid-feedback">{{ $errors->first('database_password') }}</div>
                                @endif
                            </div>

                            <hr class="my-4">

                            <div class="form-group">
                                <label for="admin_email">Admin Email</label>
                                <input type="email" class="form-control {{ $errors->has('admin_email') ? ' is-invalid ' : '' }}" id="admin_email" name="admin_email" value="{{ old('admin_email') }}" placeholder="Email">

                                @if ($errors->has('admin_email'))
                                    <div class="invalid-feedback">{{ $errors->first('admin_email') }}</div>
                                @endif
                            </div>

                            <div class="form-group">
                                <label for="admin_username">Admin Username</label>
                                <input type="text" class="form-control {{ $errors->has('admin_username') ? ' is-invalid ' : '' }}" id="admin_username" name="admin_username" value="{{ old('admin_username') }}" placeholder="username">
                                <small id="admin_username" class="form-text text-muted">Don't use spaces.</small>

                                @if ($errors->has('admin_username'))
                                    <div class="invalid-feedback">{{ $errors->first('admin_username') }}</div>
                                @endif
                            </div>

                            <div class="form-group">
                                <label for="admin_password">Admin Password</label>
                                <input type="password" class="form-control {{ $errors->has('admin_password') ? ' is-invalid ' : '' }}" id="admin_password" name="admin_password" value="{{ old('admin_password') }}" placeholder="password">

                                @if ($errors->has('admin_password'))
                                    <div class="invalid-feedback">{{ $errors->first('admin_password') }}</div>
                                @endif
                            </div>

                            <footer class="text-center">
                                <button class="btn btn-info" type="submit">Next Install</button>
                            </footer>
                        </div>
                    </form>

                </div>
            </div>
        </div>
    </div>
@endsection
