Browse Source

Change name to username

pull/260/head
Chris 6 years ago
parent
commit
6093119dde
  1. 6
      app/Http/Controllers/Auth/LoginController.php
  2. 12
      app/Http/Controllers/UserController.php
  3. 2
      app/User.php
  4. 2
      config/app.php
  5. 4
      database/migrations/2018_10_12_122907_create_users_table.php
  6. 1
      database/seeds/UsersSeeder.php
  7. 2
      resources/lang/br/app.php
  8. 2
      resources/lang/en/app.php
  9. 2
      resources/views/auth/login.blade.php
  10. 4
      resources/views/users/form.blade.php
  11. 2
      resources/views/userselect.blade.php

6
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);

12
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');

2
app/User.php

@ -15,7 +15,7 @@ class User extends Authenticatable
* @var array
*/
protected $fillable = [
'name', 'email', 'password',
'username', 'email', 'password',
];
/**

2
config/app.php

@ -14,7 +14,7 @@ return [
*/
'name' => env('APP_NAME', 'Heimdall'),
'version' => '1.5.2',
'version' => '1.5.5',
/*
|--------------------------------------------------------------------------

4
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();

1
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 {

2
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',

2
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',

2
resources/views/auth/login.blade.php

@ -14,7 +14,7 @@ $user = \App\User::currentUser();
@else
<img class="user-img" src="{{ asset('/img/heimdall-icon-small.png') }}" />
@endif
{{ $user->name }}
{{ $user->username }}
<input id="password" type="password" class="form-control" name="password" required>
<button type="submit" class="btn btn-primary">Login</button>
</div>

4
resources/views/users/form.blade.php

@ -10,8 +10,8 @@
{!! csrf_field() !!}
<div class="input">
<label>{{ __('app.user.name') }} *</label>
{!! Form::text('name', null, array('placeholder' => __('app.user.name'), 'id' => 'appname', 'class' => 'form-control')) !!}
<label>{{ __('app.user.username') }} *</label>
{!! Form::text('username', null, array('placeholder' => __('app.user.username'), 'id' => 'appname', 'class' => 'form-control')) !!}
<hr />
</div>
<div class="input">

2
resources/views/userselect.blade.php

@ -10,7 +10,7 @@
@else
<img class="user-img" src="{{ asset('/img/heimdall-icon-small.png') }}" />
@endif
{{ $user->name }}
{{ $user->username }}
</a>
@endforeach
</div>

Loading…
Cancel
Save