| <?php |
|
|
| namespace App\Http\Controllers\Auth; |
|
|
|
|
| use App\Http\Controllers\WebControllers\V1\Backend\LandingController; |
| use App\Models\User; |
|
|
| use Illuminate\Support\Facades\Auth; |
| use App\Http\Controllers\BaseController; |
| use Illuminate\Support\Facades\Hash; |
| use Illuminate\Support\Facades\Validator; |
| use Illuminate\Http\Request; |
| |
|
|
| class RegisterController extends BaseController |
| { |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
|
|
| |
| |
| |
| |
| |
| protected $redirectTo = '/'; |
|
|
| |
| |
| |
| |
| |
| public function __construct() |
| { |
| $this->middleware('guest'); |
| parent::__construct(); |
| } |
|
|
| public function getRegister() |
| { |
| if (Auth::guard()->check()) { |
| return redirect()->intended(action([LandingController::class,'index'])); |
| } |
|
|
| return view('Backend.auth.register'); |
| } |
|
|
| public function register(Request $request) |
| { |
| $data = $request->only([ |
| 'name', |
| 'email', |
| 'password' |
| ]); |
|
|
| $input = [ |
| 'name' => $data['name'], |
| 'email' => $data['email'], |
| 'password' => $data['password'], |
| ]; |
| $user = $this->create($input); |
| if ($user) { |
| Auth::login($user); |
| return redirect()->intended(action([LandingController::class,'index'])); |
| } |
|
|
| return redirect() |
| ->action([RegisterController::class,'getRegister']) |
| ->with('message', trans('message.register_fail')); |
|
|
| } |
| protected function create( $data) |
| { |
| return User::create([ |
| 'name' => $data['name'], |
| 'email' => $data['email'], |
| 'password' => Hash::make($data['password']), |
| ]); |
| } |
| } |
|
|