|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Modules\Sellers\Http\Controllers\Auth; |
|
4
|
|
|
|
|
5
|
|
|
use App\Modules\Sellers\Http\Controllers\Controller; |
|
6
|
|
|
use App\Modules\Sellers\Models\Seller; |
|
7
|
|
|
use Illuminate\Auth\Events\Registered; |
|
8
|
|
|
use Illuminate\Http\RedirectResponse; |
|
9
|
|
|
use Illuminate\Http\Request; |
|
10
|
|
|
use Illuminate\Support\Facades\Auth; |
|
11
|
|
|
use Illuminate\Support\Facades\Hash; |
|
12
|
|
|
use Illuminate\Validation\Rules; |
|
13
|
|
|
use Illuminate\View\View; |
|
14
|
|
|
|
|
15
|
|
|
class RegisteredSellerController extends Controller |
|
16
|
|
|
{ |
|
17
|
|
|
/** |
|
18
|
|
|
* Display the registration view. |
|
19
|
|
|
*/ |
|
20
|
1 |
|
public function create(): View |
|
21
|
|
|
{ |
|
22
|
1 |
|
return view('seller.auth.register'); |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* Handle an incoming registration request. |
|
27
|
|
|
* |
|
28
|
|
|
* @throws \Illuminate\Validation\ValidationException |
|
29
|
|
|
*/ |
|
30
|
1 |
|
public function store(Request $request): RedirectResponse |
|
31
|
|
|
{ |
|
32
|
1 |
|
$request->validate([ |
|
33
|
1 |
|
'name' => ['required', 'string', 'max:255'], |
|
34
|
1 |
|
'email' => ['required', 'string', 'email', 'max:255', 'unique:'.Seller::class], |
|
35
|
1 |
|
'password' => ['required', 'confirmed', Rules\Password::defaults()], |
|
36
|
1 |
|
]); |
|
37
|
|
|
|
|
38
|
1 |
|
$seller = Seller::create([ |
|
39
|
1 |
|
'name' => $request->name, |
|
40
|
1 |
|
'email' => $request->email, |
|
41
|
1 |
|
'password' => Hash::make($request->password), |
|
42
|
1 |
|
]); |
|
43
|
|
|
|
|
44
|
1 |
|
event(new Registered($seller)); |
|
45
|
|
|
|
|
46
|
1 |
|
Auth::guard('seller')->login($seller); |
|
47
|
|
|
|
|
48
|
1 |
|
return redirect('/seller'); |
|
49
|
|
|
} |
|
50
|
|
|
} |
|
51
|
|
|
|