Skip to content
This repository was archived by the owner on Apr 7, 2020. It is now read-only.
Open
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
16 changes: 12 additions & 4 deletions app/Account.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,31 @@ class Account extends Authenticatable
'password',
];

/**
* Indicates if the model should be timestamped.
*
* @var bool
*/
public $timestamps = false;

/*
|------------------------------------------------------------------------------------
| Validations
|------------------------------------------------------------------------------------
*/
public static function rules($update = false, $id = null)
{
$commun = [
'email' => "required|email|unique:accounts,email,$id",
$rules = [
'email' => 'required|email|unique:accounts,email,' . $id,
'password' => 'nullable|confirmed'
];

if ($update) {
return $commun;
return $rules;
}

return array_merge($commun, [
return array_merge($rules, [
'name' => 'required|min:6|alphanum|unique:accounts',
'email' => 'required|email|max:255|unique:accounts',
'password' => 'required|confirmed|min:6',
]);
Expand Down
8 changes: 2 additions & 6 deletions app/Http/Controllers/Auth/RegisterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class RegisterController extends Controller
*
* @var string
*/
protected $redirectTo = '/home';
protected $redirectTo = '/';

/**
* Create a new controller instance.
Expand All @@ -47,11 +47,7 @@ public function __construct()
*/
protected function validator(array $data)
{
return Validator::make($data, [
'name' => 'required|string|max:255|unique:accounts',
'email' => 'required|string|email|max:255|unique:accounts',
'password' => 'required|string|min:6|confirmed',
]);
return Validator::make($data, Account::rules());
}

/**
Expand Down
4 changes: 2 additions & 2 deletions resources/views/auth/register.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
</div>

<div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}">
<label for="password" class="text-normal text-dark">password</label>
<label for="password" class="text-normal text-dark">Password</label>
<input id="password" type="password" class="form-control" name="password" required>

@if ($errors->has('password'))
Expand All @@ -59,7 +59,7 @@
<div class="form-group">
<div class="peers ai-c jc-sb fxw-nw">
<div class="peer">
<a href="/login">I have an account</a>
<a href="{{ route('login') }}">I have an account</a>
</div>
<div class="peer">
<button class="btn btn-primary">Register</button>
Expand Down