In Laravel AuthController with in create function ,after successfull registration i want to send activation code to user registered email id.
After registration i checked it with echo"testing..." but it throws error like this
ErrorException in SessionGuard.php line 439:
Argument 1 passed to Illuminate\Auth\SessionGuard::login() must implement interface Illuminate\Contracts\Auth\Authenticatable, null given, called in C:\xampp\htdocs\sdeal\vendor\laravel\framework\src\Illuminate\Foundation\Auth\RegistersUsers.php on line 63 and defined
Authcontroller:
<?php
namespace App\Http\Controllers\Admin\Auth;
use App\Modules\Models\User\User;
use Illuminate\Http\Request;
use Validator;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ThrottlesLogins;
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
class AuthController extends Controller
{
/*
|--------------------------------------------------------------------------
| Registration & Login Controller
|--------------------------------------------------------------------------
|
| This controller handles the registration of new users, as well as the
| authentication of existing users. By default, this controller uses
| a simple trait to add these behaviors. Why don't you explore it?
|
*/
use AuthenticatesAndRegistersUsers, ThrottlesLogins;
/**
* Where to redirect users after login / registration.
*
* @var string
*/
protected $redirectTo = '/user';
protected $redirectAfterLogout = '/user/register';
protected $loginView = 'admin.auth.login';
protected $registerView = 'admin.auth.register';
/**
* Create a new authentication controller instance.
*
*/
public function __construct()
{
$this->middleware($this->guestMiddleware(), ['except' => 'logout']);
}
/**
* Get a validator for an incoming registration request.
*
* @param array $data
* @return \Illuminate\Contracts\Validation\Validator
*/
protected function validator(array $data)
{
return Validator::make($data, [
'name' => 'required|max:255',
'email' => 'required|email|max:255|unique:users',
'password' => 'required|min:6|confirmed',
]);
}
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return User
*/
protected function create(array $data)
{
$user= User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
'code'=> str_random(30),
]);
//send email with activation code
echo "testing";
// Mail::send('email.verify', $confirmation_code, function($message) {
// $message->to(Input::get('email'), Input::get('username'))
// ->subject('Verify your email address');
// });
}
/**
* Get the needed authorization credentials from the request.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
protected function getCredentials(Request $request)
{
$request = $request->only($this->loginUsername(), 'password');
// $request['type'] = config('constants.type_superuser');
return $request;
}
}
How can i solve this error