register.php
1つのuserはlaravelで用意されている処理をそのまま利用し、
<?php namespace App\Http\Controllers\AuthBuyer; use App\Buyer; use App\Rules\Hankaku; use App\Http\Controllers\Controller; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Validator; use Illuminate\Foundation\Auth\RegistersUsers; use Illuminate\Http\Request; class RegisterController extends Controller { use RegistersUsers; public function guard() { return Auth::guard('buyers'); } protected $redirectTo = '/'; public function showRegistrationForm (){ return view('authBuyer.register'); } public function __construct() { $this->middleware('guest:buyers'); } protected function create(Request $request) { $validData = $this->validate($request, [ 'buyer_name' => 'required|string|max:20|', 'email' => ['required','string','email','max:255','unique:buyers'], 'password' => ['required','string',new Hankaku,'min:8','confirmed'], ]); Buyer::create([ 'buyer_name' => $validData['buyer_name'], 'email' => $validData['email'], 'password' => Hash::make($validData['password']), ]); return redirect()->route('products.index'); } }
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。