From 6093119dde4788e104f4846a619cac84010a5e42 Mon Sep 17 00:00:00 2001 From: Chris Date: Tue, 16 Oct 2018 14:14:14 +0100 Subject: [PATCH] Change name to username --- app/Http/Controllers/Auth/LoginController.php | 6 +++++- app/Http/Controllers/UserController.php | 12 ++++++------ app/User.php | 2 +- config/app.php | 2 +- .../2018_10_12_122907_create_users_table.php | 4 ++-- database/seeds/UsersSeeder.php | 1 + resources/lang/br/app.php | 2 +- resources/lang/en/app.php | 2 +- resources/views/auth/login.blade.php | 2 +- resources/views/users/form.blade.php | 4 ++-- resources/views/userselect.blade.php | 2 +- 11 files changed, 22 insertions(+), 17 deletions(-) diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index 6a1e1efd..3688debd 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -43,6 +43,10 @@ class LoginController extends Controller $this->middleware('guest')->except('logout'); } + public function username() + { + return 'username'; + } /** * Handle a login request to the application. @@ -55,7 +59,7 @@ class LoginController extends Controller public function login(Request $request) { $current_user = User::currentUser(); - $request->merge(['email' => $current_user->email]); + $request->merge(['username' => $current_user->username]); //die(print_r($request->all())); $this->validateLogin($request); diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index d76022c1..df28a1f8 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -53,14 +53,14 @@ class UserController extends Controller public function store(Request $request) { $validatedData = $request->validate([ - 'name' => 'required|max:255|unique:users', - 'email' => 'required|email|unique:users', + 'username' => 'required|max:255|unique:users', + 'email' => 'required|email', 'password' => 'nullable|confirmed', 'password_confirmation' => 'nullable' ]); $user = new User; - $user->name = $request->input('name'); + $user->username = $request->input('username'); $user->email = $request->input('email'); $user->public_front = $request->input('public_front'); @@ -119,14 +119,14 @@ class UserController extends Controller public function update(Request $request, User $user) { $validatedData = $request->validate([ - 'name' => 'required|max:255|unique:users,name,'.$user->id, - 'email' => 'required|email|unique:users,email,'.$user->id, + 'username' => 'required|max:255|unique:users,username,'.$user->id, + 'email' => 'required|email', 'password' => 'nullable|confirmed', 'password_confirmation' => 'nullable' ]); //die(print_r($request->all())); - $user->name = $request->input('name'); + $user->username = $request->input('username'); $user->email = $request->input('email'); $user->public_front = $request->input('public_front'); diff --git a/app/User.php b/app/User.php index a5bcac1a..d74928ac 100644 --- a/app/User.php +++ b/app/User.php @@ -15,7 +15,7 @@ class User extends Authenticatable * @var array */ protected $fillable = [ - 'name', 'email', 'password', + 'username', 'email', 'password', ]; /** diff --git a/config/app.php b/config/app.php index 914ed33c..1ee9b966 100644 --- a/config/app.php +++ b/config/app.php @@ -14,7 +14,7 @@ return [ */ 'name' => env('APP_NAME', 'Heimdall'), - 'version' => '1.5.2', + 'version' => '1.5.5', /* |-------------------------------------------------------------------------- diff --git a/database/migrations/2018_10_12_122907_create_users_table.php b/database/migrations/2018_10_12_122907_create_users_table.php index 6f462806..cadc2344 100644 --- a/database/migrations/2018_10_12_122907_create_users_table.php +++ b/database/migrations/2018_10_12_122907_create_users_table.php @@ -15,8 +15,8 @@ class CreateUsersTable extends Migration { Schema::create('users', function (Blueprint $table) { $table->increments('id'); - $table->string('name'); - $table->string('email')->unique(); + $table->string('username')->unique(); + $table->string('email'); $table->string('avatar')->nullable(); $table->string('password')->nullable(); $table->string('autologin')->nullable()->index(); diff --git a/database/seeds/UsersSeeder.php b/database/seeds/UsersSeeder.php index 615b022b..93503ede 100644 --- a/database/seeds/UsersSeeder.php +++ b/database/seeds/UsersSeeder.php @@ -17,6 +17,7 @@ class UsersSeeder extends Seeder $user = new User; $user->id = 1; $user->name = 'Admin'; + $user->username = 'admin'; $user->email = 'admin@test.com'; $user->save(); } else { diff --git a/resources/lang/br/app.php b/resources/lang/br/app.php index 4039c35d..930bc11d 100644 --- a/resources/lang/br/app.php +++ b/resources/lang/br/app.php @@ -76,7 +76,7 @@ return [ 'user.user_list' => 'Comercial', 'user.add_user' => 'Adicionar usuários', - 'user.name' => 'Nome', + 'user.username' => 'Nome de usuário', 'user.avatar' => 'Avatar', 'user.email' => 'O email', 'user.password_confirm' => 'Confirme a Senha', diff --git a/resources/lang/en/app.php b/resources/lang/en/app.php index b9116afd..2148839e 100644 --- a/resources/lang/en/app.php +++ b/resources/lang/en/app.php @@ -76,7 +76,7 @@ return [ 'user.user_list' => 'Users', 'user.add_user' => 'Add user', - 'user.name' => 'Name', + 'user.username' => 'Username', 'user.avatar' => 'Avatar', 'user.email' => 'Email', 'user.password_confirm' => 'Confirm Password', diff --git a/resources/views/auth/login.blade.php b/resources/views/auth/login.blade.php index 883bb16a..19f39865 100644 --- a/resources/views/auth/login.blade.php +++ b/resources/views/auth/login.blade.php @@ -14,7 +14,7 @@ $user = \App\User::currentUser(); @else @endif - {{ $user->name }} + {{ $user->username }} diff --git a/resources/views/users/form.blade.php b/resources/views/users/form.blade.php index 290419d9..f7b1d4b0 100644 --- a/resources/views/users/form.blade.php +++ b/resources/views/users/form.blade.php @@ -10,8 +10,8 @@ {!! csrf_field() !!}
- - {!! Form::text('name', null, array('placeholder' => __('app.user.name'), 'id' => 'appname', 'class' => 'form-control')) !!} + + {!! Form::text('username', null, array('placeholder' => __('app.user.username'), 'id' => 'appname', 'class' => 'form-control')) !!}
diff --git a/resources/views/userselect.blade.php b/resources/views/userselect.blade.php index 3295ad53..97f67db8 100644 --- a/resources/views/userselect.blade.php +++ b/resources/views/userselect.blade.php @@ -10,7 +10,7 @@ @else @endif - {{ $user->name }} + {{ $user->username }} @endforeach