Page MenuHomeDevCentral

No OneTemporary

diff --git a/app/Services/Registrar.php b/app/Services/Registrar.php
index acadd4f..9f3df19 100644
--- a/app/Services/Registrar.php
+++ b/app/Services/Registrar.php
@@ -1,41 +1,41 @@
<?php namespace AuthGrove\Services;
use AuthGrove\User;
use Validator;
use Illuminate\Contracts\Auth\Registrar as RegistrarContract;
class Registrar implements RegistrarContract {
/**
* Get a validator for an incoming registration request.
*
* @param array $data
* @return \Illuminate\Contracts\Validation\Validator
*/
public function validator(array $data)
{
return Validator::make($data, [
'username' => 'required|max:255|unique:users',
- 'fullname' => 'required|max:255',
+ 'fullname' => 'max:255',
'email' => 'sometimes|required|email|max:255|unique:users',
'password' => 'required|confirmed|min:6',
]);
}
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return User
*/
public function create(array $data)
{
return User::create([
- 'name' => $data['name'],
+ 'username' => $data['username'],
'fullname' => $data['fullname'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
]);
}
}
diff --git a/app/User.php b/app/User.php
index 7ad097e..49d542d 100644
--- a/app/User.php
+++ b/app/User.php
@@ -1,34 +1,43 @@
<?php namespace AuthGrove;
use Illuminate\Auth\Authenticatable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Auth\Passwords\CanResetPassword;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
class User extends Model implements AuthenticatableContract, CanResetPasswordContract {
use Authenticatable, CanResetPassword;
/**
* The database table used by the model.
*
* @var string
*/
protected $table = 'users';
/**
* The attributes that are mass assignable.
*
* @var array
*/
- protected $fillable = ['name', 'email', 'password'];
+ protected $fillable = ['username', 'fullname', 'email', 'password'];
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
protected $hidden = ['password', 'remember_token'];
+ /**
+ * Gets the full name of an user, or if not defined, the username.
+ */
+ public function getName () {
+ if ($this->attributes['fullname'] !== "") {
+ return $this->attributes['fullname'];
+ }
+ return $this->attributes['username'];
+ }
}

File Metadata

Mime Type
text/x-diff
Expires
Tue, Jul 29, 14:21 (11 h, 20 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2847458
Default Alt Text
(2 KB)

Event Timeline