質問するログイン新規登録

質問編集履歴

2

2021/08/10 06:44

投稿

teityann1225
teityann1225

スコア158

title CHANGED
File without changes
body CHANGED
@@ -82,4 +82,18 @@
82
82
  $table->foreignId('character_id');
83
83
  });
84
84
  }
85
+ ```
86
+
87
+ Create部分
88
+ ```
89
+ $report = Report::create([
90
+ "user_id" => Auth::id(),
91
+ "title" => $request->input('report-title'),
92
+ "description" => $request->input('report-description'),
93
+ "character_id" => $request->input('character'),
94
+ "game_mode_id" => $request->input('game_mode'),
95
+ "account_name" => $request->input('account-name', 'none'),
96
+ "is_account_name_null" => $request->input('cantReadCheck', false) == "on",
97
+ "time_unknown" => $request->input('unknown_time_check', false) == "on",
98
+ "occurrence_date" => $date, ]);
85
99
  ```

1

uuidの設定箇所のコードを追記

2021/08/10 06:44

投稿

teityann1225
teityann1225

スコア158

title CHANGED
File without changes
body CHANGED
@@ -28,6 +28,16 @@
28
28
  public function scopeGetUudFromId($query,$uuid){
29
29
  return $query->where('report_uuid',$uuid)->first()->report_uuid;
30
30
  }
31
+
32
+ ** 省略**
33
+ protected static function boot(): void
34
+ {
35
+ parent::boot();
36
+ self::creating(function ($model){
37
+ $model->report_uuid = (string) Str::orderedUuid();
38
+ });
39
+ }
40
+
31
41
  ```
32
42
 
33
43
  Migrationファイル