@rameezisrar Thanks, but it didn't work...
Spark 8.0 (Laravel 5.8)
app/database/migrations/2019_07_30_171753_create_users_table.php:
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('email');
$table->string('username')->unique();
$table->string('timezone');
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->rememberToken();
$table->text('photo_url')->nullable();
$table->tinyInteger('uses_two_factor_auth')->default(0);
$table->string('authy_id')->nullable();
$table->string('country_code', 10)->nullable();
$table->string('phone', 25)->nullable();
$table->string('two_factor_reset_code', 100)->nullable();
$table->integer('current_team_id')->nullable();
$table->string('stripe_id')->nullable();
$table->string('current_billing_plan')->nullable();
$table->string('card_brand')->nullable();
$table->string('card_last_four')->nullable();
$table->string('card_country')->nullable();
$table->string('billing_address')->nullable();
$table->string('billing_address_line_2')->nullable();
$table->string('billing_city')->nullable();
$table->string('billing_state')->nullable();
$table->string('billing_zip', 25)->nullable();
$table->string('billing_country', 2)->nullable();
$table->string('vat_id', 50)->nullable();
$table->text('extra_billing_information')->nullable();
$table->timestamp('trial_ends_at')->nullable();
$table->timestamp('last_read_announcements_at')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('users');
}
}
app\User.php:
<?php
namespace App;
use Laravel\Spark\CanJoinTeams;
use Laravel\Spark\User as SparkUser;
class User extends SparkUser
{
use CanJoinTeams;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name',
'email',
'password',
'username'
];
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
protected $hidden = [
'password',
'remember_token',
'authy_id',
'country_code',
'phone',
'card_brand',
'card_last_four',
'card_country',
'billing_address',
'billing_address_line_2',
'billing_city',
'billing_zip',
'billing_country',
'extra_billing_information',
];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [
'trial_ends_at' => 'datetime',
'uses_two_factor_auth' => 'boolean',
];
}
app/resources/views/vendor/spark/auth/login.blade.php
@extends('spark::layouts.app')
@section('content')
<div class="container">
<div class="row justify-content-center">
<div class="col-lg-8">
<div class="card card-default">
<div class="card-header">{{__('Login')}}</div>
<div class="card-body">
@include('spark::shared.errors')
<form role="form" method="POST" action="/login">
{{ csrf_field() }}
<!-- Username -->
<div class="form-group row">
<label class="col-md-4 col-form-label text-md-right">Username</label>
<div class="col-md-6">
<input type="text" class="form-control" name="username" value="{{ old('username') }}" autofocus>
</div>
</div>
<!-- Password -->
<div class="form-group row">
<label class="col-md-4 col-form-label text-md-right">{{__('Password')}}</label>
<div class="col-md-6">
<input type="password" class="form-control" name="password">
</div>
</div>
<!-- Remember Me -->
<div class="form-group row">
<div class="col-md-6 offset-md-4">
<div class="form-check">
<label class="form-check-label">
<input type="checkbox" name="remember" class="form-check-input"> {{__('Remember Me')}}
</label>
</div>
</div>
</div>
<!-- Login Button -->
<div class="form-group row mb-0">
<div class="col-md-6 offset-md-4">
<button type="submit" class="btn btn-primary">
{{__('Login')}}
</button>
<a class="btn btn-link" href="{{ url('/password/reset') }}">{{__('Forgot Your Password?')}}</a>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
@endsection
app\Http\Controllers\Auth\LoginController.php
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
class LoginController extends Controller
{
/*
|--------------------------------------------------------------------------
| Login Controller
|--------------------------------------------------------------------------
|
| This controller handles authenticating users for the application and
| redirecting them to your home screen. The controller uses a trait
| to conveniently provide its functionality to your applications.
|
*/
use AuthenticatesUsers;
/**
* Where to redirect users after login.
*
* @var string
*/
protected $redirectTo = '/home';
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest')->except('logout');
}
protected function credentials(Request $request)
{
$field = $this->field($request);
return [
$field => $request->get($this->username()),
'password' => $request->get('password'),
];
}
public function field(Request $request)
{
$email = $this->username();
return filter_var($request->get($email), FILTER_VALIDATE_EMAIL) ? $email : 'username';
}
protected function validateLogin(Request $request)
{
$field = $this->field($request);
$messages = ["{$this->username()}.exists" => 'The account you are trying to login is not registered or it has been disabled.'];
$this->validate($request, [
$this->username() => "required|exists:users,{$field}",
'password' => 'required',
], $messages);
}
}
