From bbbea73a051f479c3408dbcef207d6558a9fa724 Mon Sep 17 00:00:00 2001 From: shibafu Date: Thu, 23 Jul 2020 22:57:21 +0900 Subject: [PATCH] =?UTF-8?q?Webhook=E8=AD=98=E5=88=A5=E5=90=8D=E9=87=8D?= =?UTF-8?q?=E8=A4=87=E3=83=81=E3=82=A7=E3=83=83=E3=82=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/SettingController.php | 11 ++++++++++- resources/views/setting/webhooks.blade.php | 5 ++++- 2 files changed, 14 insertions(+), 2 deletions(-) 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