git -C '/home/opc/rocketa.git' show 129cb6c -- app/Rules/TrackingLink.phpcommit 129cb6c2c3609d213f46aebae04b7bebb7c8f377
Author: Satoshi Ujihara <satoshi_ujihara@fivegate.jp>
Date: Thu Nov 6 15:06:44 2025 +0900
バリデーション追加
成果通信まわり修正
diff --git a/app/Rules/TrackingLink.php b/app/Rules/TrackingLink.php
new file mode 100644
index 0000000..b24e3c6
--- /dev/null
+++ b/app/Rules/TrackingLink.php
@@ -0,0 +1,58 @@
+<?php
+
+namespace App\Rules;
+
+use Illuminate\Contracts\Validation\Rule;
+
+class TrackingLink implements Rule
+{
+ /**
+ * Create a new rule instance.
+ *
+ * @return void
+ */
+ public function __construct()
+ {
+
+ }
+
+ /**
+ * Determine if the validation rule passes.
+ *
+ * @param string $attribute
+ * @param mixed $value
+ * @return bool
+ */
+ public function passes($attribute, $value)
+ {
+ if(preg_match('/^https?:\/\//', $value)) {
+ $query = parse_url($value, PHP_URL_QUERY);
+ if (!$query) return true; // クエリがないならOK
+
+ // クエリを "&" で分解
+ $params = explode('&', $query);
+
+ $keys = [];
+ foreach ($params as $param) {
+ $key = explode('=', $param, 2)[0]; // パラメータ名だけ取り出す
+ if (in_array($key, $keys, true)) {
+ return false; // 重複あり
+ }
+ $keys[] = $key;
+ }
+ return true; // 重複なし
+
+ }
+ return false;
+ }
+
+ /**
+ * Get the validation error message.
+ *
+ * @return string
+ */
+ public function message()
+ {
+ return 'https://またはhttp://から始まるGETパラメータが重複しないURLを設定してください。';
+ }
+}
\ No newline at end of file