概要 開始日と終了日のテキストボックスがある。 それぞれ必須入力ではなく、指定可能期間は本日〜1ヶ月後とする。 開始日が指定された場合のみ、「開始日 <= 終了日」の条件が発生。 コード public function rules() { $today = date("Y-m-d"); $nextmonth = date("Y-m-d", strtotime("1 month")); return [ 'date_start_at' => 'nullable|date|after_or_equal:' . $today . '|before:' . $nextmonth, 'date_end_at' => 'nullable|date|after_or_equal:' . $today . '|before:' . $nextmonth, ]; } 「after_or_equal:toda
![[PHP][Laravel][バリデーション] 開始と終了の日付バリデーション処理 - 1分技術ブログ](https://cdn-ak-scissors.b.st-hatena.com/image/square/0a63f969526f7239e2d1acdcaac1a155d174e792/height=288;version=1;width=512/https%3A%2F%2Fcdn.image.st-hatena.com%2Fimage%2Fscale%2F89ebd939bca01213e78d8a39adcbc8becc00e728%2Fbackend%3Dimagemagick%3Bversion%3D1%3Bwidth%3D1300%2Fhttps%253A%252F%252Fimages-fe.ssl-images-amazon.com%252Fimages%252FI%252F51M9CvLpz3L._SL160_.jpg)