質問編集履歴
2
カスタムバリデーションのファンクションを追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -22,6 +22,8 @@
|
|
22
22
|
|
23
23
|
|
24
24
|
|
25
|
+
```ここに言語を入力
|
26
|
+
|
25
27
|
public function rules()
|
26
28
|
|
27
29
|
{
|
@@ -38,6 +40,42 @@
|
|
38
40
|
|
39
41
|
}
|
40
42
|
|
43
|
+
```
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
```ここに言語を入力
|
48
|
+
|
49
|
+
public function validateMailcheck($attribute, $value, $parameters){
|
50
|
+
|
51
|
+
try{
|
52
|
+
|
53
|
+
$count= Entry::where('mail',$value)->count();
|
54
|
+
|
55
|
+
//もしDBにそのメールアドレスが存在した場合にはelseに入る
|
56
|
+
|
57
|
+
if ($count == 0){
|
58
|
+
|
59
|
+
return true;
|
60
|
+
|
61
|
+
}else{
|
62
|
+
|
63
|
+
return false;
|
64
|
+
|
65
|
+
}
|
66
|
+
|
67
|
+
}catch (\Exception $e){
|
68
|
+
|
69
|
+
exit(redirect('entry/input')->withErrors(['systemError' => 'システムエラーが発生しました。お手数ですが登録を最初からやり直してください']));
|
70
|
+
|
71
|
+
}
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
}
|
76
|
+
|
77
|
+
```
|
78
|
+
|
41
79
|
|
42
80
|
|
43
81
|
### 試したこと
|
1
コード詳細を記入しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -22,7 +22,21 @@
|
|
22
22
|
|
23
23
|
|
24
24
|
|
25
|
-
|
25
|
+
public function rules()
|
26
|
+
|
27
|
+
{
|
28
|
+
|
29
|
+
return [
|
30
|
+
|
31
|
+
'name' => ['required', 'string','max:30'],
|
32
|
+
|
33
|
+
"mail" => ['required','unique:users,mail','max:60','email'],
|
34
|
+
|
35
|
+
'gender' => ['required','integer','between:1,2'],
|
36
|
+
|
37
|
+
];
|
38
|
+
|
39
|
+
}
|
26
40
|
|
27
41
|
|
28
42
|
|