Hi, i am using the Nwidart Laravel-Modules and so far i have 3 modules, 1)Admin, 2)Core, and 3)Users that handdles user login/registration and so on. The problem is i can's login or register users even though i have the rquirments put inplace.
i have my routes like so.
// join routes
Route::get('join', 'JoinController@show')->name('join.show');;
Route::post('join', 'JoinController@join')->name('join.perform');;}
And my joincontroller like so.
<?php
namespace Modules\Auth\Http\Controllers;
use Illuminate\Contracts\Support\Renderable;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use Modules\Auth\Entities\User;
use Modules\Auth\Http\Requests\JoinRequest;
use Session;
use Hash;
class JoinController extends Controller
{
/**
* Display register page.
*
* @return \Illuminate\Http\Response
*/
public function show()
{
return view('auth::templates/pages.join');
}
/**
* Handle account registration request
*
* @param JoinRequest $request
*
* @return \Illuminate\Http\Response
*/
public function join(JoinRequest $request)
{
$user = User::create($request->validated());
auth()->login($user);
return redirect()->intended('auth::templates.pages.home')->with('success', "Account successfully created.");
}
}
And my join view like so.
<form method="post" action="{{ route('join.perform') }}">
<input type="hidden" name="_token" value="{{ csrf_token() }}" />
<div class="form-group">
<input type="text" name="username" value="{{ old('username') }}" required="required"/>
@if ($errors->has('username'))
<span class="text-danger text-left">{{ $errors->first('username') }}</span>
@endif
<label class="control-label" for="input">User Name</label><i class="mtrl-select"></i>
</div>
<div class="form-group">
<input type="password" name="password" value="{{ old('password') }}" required="required"/>
@if ($errors->has('password'))
<span class="text-danger text-left">{{ $errors->first('password') }}</span>
@endif
<label class="control-label" for="input">Password</label><i class="mtrl-select"></i>
</div>
<div class="form-group">
<input type="password" name="password_confirmation" value="{{ old('password_confirmation') }}" required="required"/>
@if ($errors->has('password_confirmation'))
<span class="text-danger text-left">{{ $errors->first('password_confirmation') }}</span>
@endif
<label class="control-label" for="input">Confirm Password</label><i class="mtrl-select"></i>
</div>
<div class="form-group">
<input type="email" name="email" value="{{ old('email') }}" required="required"/>
@if ($errors->has('email'))
<span class="text-danger text-left">{{ $errors->first('email') }}</span>
@endif
<label class="control-label" for="input"></label><i class="mtrl-select"></i>
</div>
<a href="#" title="" class="already-have">Already have an account</a>
<div class="submit-btns">
<button class="mtr-btn signin" type="submit"><span>Register</span></button>
</div>
</form>
And users model located at Modules/Auth/Entities like so.
<?php
namespace Modules\Auth\Entities;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class User extends Model
{
use HasFactory;
protected $fillable = [
'name',
'email',
'username',
'password',
];
protected static function newFactory()
{
return \Modules\Auth\Database\factories\UserFactory::new();
}
/**
* Always encrypt the password when it is updated.
*
* @param $value
* @return string
*/
public function setPasswordAttribute($value)
{
$this->attributes['password'] = bcrypt($value);
}
}
And Joinrequest like so.
<?php
namespace Modules\Auth\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class JoinRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'email' => 'required|email:rfc,dns|unique:users,email',
'username' => 'required|unique:users,username',
'password' => 'required|min:8',
'password_confirmation' => 'required|same:password'
];
}
}
Now i am lost and confused. Please help.
Thanks