【问题标题】:How prevent user to input end_date before start_date in LARAVEL 8如何防止用户在 LARAVEL 8 中的 start_date 之前输入 end_date
【发布时间】:2023-03-20 05:12:01
【问题描述】:

我有两个日期,开始日期和结束日期我想阻止用户在开始日期之前输入结束日期,如下所示:1/1/2018 -> 结束日期,2/2/2018 -> 开始日期。我想要这样:2018 年 1 月 1 日 -> 开始日期,2018 年 2 月 2 日 -> 结束日期。 我使用了这个代码,但它不起作用,仍然接受它并在数据库中注册

'courses.*.start_date' => 'required|date',
'courses.*.end_date' => 'required|date|after_or_equal:end_date'

【问题讨论】:

    标签: laravel laravel-8


    【解决方案1】:

    您应该将start_date 放入end_date 的验证中

    'courses.*.start_date' => 'required|date',
    'courses.*.end_date' => 'required|date|after_or_equal:start_date'
    

    【讨论】:

      猜你喜欢
      • 2022-01-22
      • 1970-01-01
      • 1970-01-01
      • 2021-09-27
      • 2021-12-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多