<?php
namespace App\Http\Controllers\Auth;
use App\Elancer;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use Illuminate\Auth\Events\Registered;
class ElancerRegisterController extends Controller
{
public function __construct()
{
$this->middleware('guest');
}
public function showRegistrationForm()
{
return view('auth.elancer-register');
}
public function register(Request $request)
{
$this->validate($request, [
'name' => 'required|string|max:255',
'email' => 'required|string|email|max:255|unique:users',
'password' => 'required|string|min:6|confirmed'
]);
$elancer = Elancer::create([
'name' => $request['name'],
'email' => $request['email'],
'password' => Hash::make($request['password']),
]);
event(new Registered($elancer));
$this->guard()->login($elancer);
return redirect()->route('elancer.home');
}
protected function guard()
{
return Auth::guard('elancer');
}
}