diff --git a/app/Http/Controllers/SettingController.php b/app/Http/Controllers/SettingController.php index f57d897..7efb103 100644 --- a/app/Http/Controllers/SettingController.php +++ b/app/Http/Controllers/SettingController.php @@ -87,7 +87,16 @@ class SettingController extends Controller public function storeWebhooks(Request $request) { $validated = $request->validate([ - 'name' => 'required|string|max:255' + 'name' => [ + 'required', + 'string', + 'max:255', + Rule::unique('checkin_webhooks', 'name')->where(function ($query) { + return $query->where('user_id', Auth::id()); + }) + ] + ], [], [ + 'name' => '名前' ]); if (Auth::user()->checkinWebhooks()->count() >= CheckinWebhook::PER_USER_LIMIT) { diff --git a/resources/views/setting/webhooks.blade.php b/resources/views/setting/webhooks.blade.php index 7e62d73..bc181ed 100644 --- a/resources/views/setting/webhooks.blade.php +++ b/resources/views/setting/webhooks.blade.php @@ -20,8 +20,11 @@ {{ csrf_field() }}
- + 後で分かるように名前を付けておいてください。 + @if ($errors->has('name')) +
{{ $errors->first('name') }}
+ @endif