回答編集履歴
3
コードの修正
test
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
+
```php
|
2
|
+
|
1
|
-
protected function create(array $data)
|
3
|
+
protected function create(array $data)
|
2
4
|
|
3
5
|
{
|
4
6
|
|
@@ -39,3 +41,5 @@
|
|
39
41
|
]);
|
40
42
|
|
41
43
|
}
|
44
|
+
|
45
|
+
```
|
2
コードの修正
test
CHANGED
@@ -1,6 +1,22 @@
|
|
1
1
|
protected function create(array $data)
|
2
2
|
|
3
3
|
{
|
4
|
+
|
5
|
+
// 最後に登録されたユーザーの10桁の数値を取得
|
6
|
+
|
7
|
+
$last_user = DB::table('users')->get()->last();
|
8
|
+
|
9
|
+
if (isset($last_user)) {
|
10
|
+
|
11
|
+
$max_number = $last_user->unique_number;
|
12
|
+
|
13
|
+
// 1人目のユーザーの場合は1000000000を付与
|
14
|
+
|
15
|
+
} else {
|
16
|
+
|
17
|
+
$max_number = 1000000000;
|
18
|
+
|
19
|
+
}
|
4
20
|
|
5
21
|
$user = User::create([
|
6
22
|
|
@@ -8,20 +24,18 @@
|
|
8
24
|
|
9
25
|
'first_name' => $data['first_name'],
|
10
26
|
|
27
|
+
'last_name_kana' => $data['last_name_kana'],
|
28
|
+
|
29
|
+
'first_name_kana' => $data['first_name_kana'],
|
30
|
+
|
11
31
|
'email' => $data['email'],
|
12
32
|
|
13
33
|
'type' => $data['type'],
|
14
34
|
|
15
35
|
'password' => Hash::make($data['password']),
|
16
36
|
|
37
|
+
'unique_number' => $max_number + 1
|
38
|
+
|
17
39
|
]);
|
18
40
|
|
19
|
-
$user['10digits_id'] = 1000000000 + $user['id'];
|
20
|
-
|
21
|
-
$user->save();
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
return $user;
|
26
|
-
|
27
41
|
}
|
1
不要なコードの削除
test
CHANGED
@@ -7,10 +7,6 @@
|
|
7
7
|
'last_name' => $data['last_name'],
|
8
8
|
|
9
9
|
'first_name' => $data['first_name'],
|
10
|
-
|
11
|
-
'last_name_kana' => $data['last_name_kana'],
|
12
|
-
|
13
|
-
'first_name_kana' => $data['first_name_kana'],
|
14
10
|
|
15
11
|
'email' => $data['email'],
|
16
12
|
|