Register form and functionally

This commit is contained in:
Kyle
2017-08-11 16:50:14 +00:00
parent 3f61b82b11
commit 5b83ca3e9b
7 changed files with 103 additions and 79 deletions

View File

@@ -5,8 +5,12 @@ namespace App\Http\Controllers\Auth;
use Validator;
use App\Models\Role;
use App\Models\User;
use App\Models\Airport;
use App\Models\Airline;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\RegistersUsers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;
class RegisterController extends Controller
{
@@ -32,7 +36,12 @@ class RegisterController extends Controller
public function showRegistrationForm()
{
return $this->view('auth.register');
$airports = Airport::all();
$airlines = Airline::all();
return $this->view('auth.register', [
'airports' => $airports,
'airlines' => $airlines,
]);
}
/**
@@ -56,26 +65,34 @@ class RegisterController extends Controller
return Validator::make($data, [
'name' => 'required|max:255',
'email' => 'required|email|max:255|unique:users',
'airline' => 'required',
'home_airport' => 'required',
'password' => 'required|min:5|confirmed',
]);
}
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return User
*/
protected function create(array $data)
public function register()
{
$user = User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
// Validate
$this->validate(request(), [
'name' => 'required',
'email' => 'required|email',
'airline' => 'required',
'home_airport' => 'required',
'password' => 'required|confirmed'
]);
$role = Role::where('name', 'admin')->first();
# TODO: I'm just feeling we need to do something with Ranking? I forgot.
$user = User::create(['name' => request('name'),
'email' => request('email'),
'airline_id' => request('airline'),
'home_airport_id' => request('home_airport'),
'curr_airport_id' => request('home_airport'),
'password' => Hash::make(request('password')),
'rank_id' => 1]);
//Attach the user roles
$role = Role::where('name', 'user')->first();
$user->attachRole($role);
return $user->refresh();
return $this->view('auth.registered');
}
}

View File

@@ -60,6 +60,10 @@ class User extends Authenticatable
'name',
'email',
'password',
'airline_id',
'home_airport_id',
'curr_airport_id',
'rank_id'
];
/**
@@ -86,14 +90,6 @@ class User extends Authenticatable
return $this->airline->code.str_pad($this->id, 3, '0', STR_PAD_LEFT);
}
public function gravatar()
{
$size = 80;
$default = 'https://en.gravatar.com/userimage/12856995/7c7c1da6387853fea65ff74983055386.png';
return "https://www.gravatar.com/avatar/" .
md5( strtolower( trim( $this->email) ) ) . "?d=" . urlencode( $default ) . "&s=" . $size;
}
/**
* Foreign Keys
*/

View File

@@ -55,4 +55,9 @@ class PilotService extends BaseService
return $pilot;
}
public function create()
{
}
}

View File

@@ -50,7 +50,7 @@
</div>
<div class="pull-left">
<h6>
<a href="#pablo" class="link">Create Account</a>
<a href="{{ url('/register') }}" class="link">Create Account</a>
</h6>
</div>
<div class="pull-right">

View File

@@ -2,80 +2,76 @@
@section('content')
<div class="row">
<div class="col-sm-3 push-3"></div>
<div class="col-sm-6">
<div class="col-sm-4"></div>
<div class="col-sm-4">
<form class="form-signin" role="form" method="POST" action="{{ url('/register') }}">
{{ csrf_field() }}
<div class="panel periodic-login">
<div class="panel-body text-center">
{{--<h1 class="atomic-symbol">Mi</h1>--}}
{{--<p class="atomic-mass">14.072110</p>
<p class="element-name">Miminium</p>--}}
<p><img src="assets/frontend/img/logo_login.png" /></p>
{{--<i class="icons icon-arrow-down"></i>--}}
<div class="form-group{{ $errors->has('name') ? ' has-error' : '' }} form-animate-text" style="margin-top:40px !important;">
<input id="name" type="text" class="form-text" name="name" value="{{ old('name') }}" required autofocus>
@if ($errors->has('name'))
<span class="help-block">
<strong>{{ $errors->first('name') }}</strong>
</span>
@endif
<span class="bar"></span>
<label for="email" class="col-md-4 control-label">name</label>
<h4>Register</h4>
<label for="name" class="col-md-4 control-label">Full Name</label>
<div class="input-group form-group-no-border{{ $errors->has('name') ? ' has-danger' : '' }}">
<input id="name" type="text" class="form-control" name="name" value="{{ old('name') }}" placeholder="Full Name" required>
</div>
@if ($errors->has('name'))
<p class="text-danger">{{ $errors->first('name') }}</p>
@endif
<div class="form-group{{ $errors->has('email') ? ' has-error' : '' }} form-animate-text"
style="margin-top:40px !important;">
<input id="email" type="email" class="form-text" name="email" value="{{ old('email') }}" required autofocus>
@if ($errors->has('email'))
<span class="help-block">
<strong>{{ $errors->first('email') }}</strong>
</span>
@endif
<span class="bar"></span>
<label for="email" class="col-md-4 control-label">email</label>
<label for="email" class="col-md-4 control-label">Email Address</label>
<div class="input-group form-group-no-border{{ $errors->has('email') ? ' has-danger' : '' }}">
<input id="email" type="email" class="form-control" name="email" value="{{ old('email') }}" placeholder="Email Address" required>
</div>
@if ($errors->has('email'))
<p class="text-danger">{{ $errors->first('email') }}</p>
@endif
<div class="form-group{{ $errors->has('password') ? ' has-error' : '' }} form-animate-text" style="margin-top:40px !important;">
<input id="password" type="password" class="form-text" name="password" required>
@if ($errors->has('password'))
<span class="help-block">
<strong>{{ $errors->first('password') }}</strong>
</span>
@endif
<span class="bar"></span>
<label for="email" class="col-md-4 control-label">password</label>
<label for="airline" class="col-md-4 control-label">Airline</label>
<div class="input-group form-group-no-border{{ $errors->has('airline') ? ' has-danger' : '' }}">
<select name="airline" id="airline" class="form-control" required>
@foreach($airlines as $airline)
<option value="{{ $airline->id }}">{{ $airline->code }} - {{ $airline->name }}</option>
@endforeach
</select>
</div>
@if ($errors->has('airline'))
<p class="text-danger">{{ $errors->first('airline') }}</p>
@endif
<div class="form-group{{ $errors->has('password_confirmation') ? ' has-error' : '' }} form-animate-text" style="margin-top:40px !important;">
<input id="password-confirm" type="password" class="form-text" name="password_confirmation" required>
@if ($errors->has('password_confirmation'))
<span class="help-block">
<strong>{{ $errors->first('password_confirmation') }}</strong>
</span>
@endif
<span class="bar"></span>
<label for="email" class="col-md-4 control-label">confirm password</label>
<label for="home_airport" class="col-md-4 control-label">Home Airport</label>
<div class="input-group form-group-no-border{{ $errors->has('home_airport') ? ' has-danger' : '' }}">
<select name="home_airport" id="home_airport" class="form-control" required>
@foreach($airports as $airport)
<option value="{{ $airport->id }}">{{ $airport->icao }} - {{ $airport->name }}</option>
@endforeach
</select>
</div>
@if ($errors->has('home_airport'))
<p class="text-danger">{{ $errors->first('home_airport') }}</p>
@endif
<div class="text-center">
<a href="/login" class="btn btn-primary">Login</a>
<button type="submit" class="btn btn-primary">
Register
</button>
<label for="password" class="col-md-4 control-label">Password</label>
<div class="input-group form-group-no-border{{ $errors->has('password') ? ' has-danger' : '' }}">
<input id="password" type="password" class="form-control" name="password" value="" placeholder="Password" required>
</div>
@if ($errors->has('password'))
<p class="text-danger">{{ $errors->first('password') }}</p>
@endif
<label for="password_confirmation" class="col-md-4 control-label">Confirm Password</label>
<div class="input-group form-group-no-border{{ $errors->has('password_confirmation') ? ' has-danger' : '' }}">
<input id="password_confirmation" type="password" class="form-control" name="password_confirmation" value="" placeholder="Confirm Password" required>
</div>
@if ($errors->has('password_confirmation'))
<p class="text-danger">{{ $errors->first('password_confirmation') }}</p>
@endif
<button type="submit" class="btn btn-primary">Register</button>
</div>
</div>
</form>
</div>
</div>
<div class="col-sm-4"></div>
</div>
@endsection

View File

@@ -0,0 +1,10 @@
@extends('layouts.default.app')
@section('content')
<div class="container registered-page">
<h3>Registration Confirmation</h3>
<p>Your application has been submitted. It requires staff member approval, once a staff member has reviewed your application, you will receive an email confirmation.</p>
</div>
@endsection

View File

@@ -12,7 +12,7 @@ Route::group([
Route::match(['get', 'put'], 'airports/fuel', 'AirportController@fuel');
Route::resource('airports', 'AirportController');
Route::resource('aircraftclasses', 'AircraftClassController');
#Route::resource('aircraftclasses', 'AircraftClassController');
Route::resource('fares', 'FareController');
# subfleet