开始日期时间和结束日期时间的验证

Validation of starting dateTime and ending datetime

我想用两列在函数中进行验证: 1) entry_dateTime 2) close_dateTime

close_datetime will be more than entry_dateTime. How can I do validation?

例如entry_dateTime1/1/201809:15:14,那么close_dateTime必须大于entry_dateTime,2/1/201908:00:00

我的函数:

public function store(Request $request)
    {
      $input = $request->all();

        $tradeID= Auth::user()->trade()->create($input);

        $reasons=$request->input('reason');

                        //Loop for creating KEY as Value
                        $data = [];
                        foreach($reasons as $key => $value) {

                            $data[] = ['reason_id' => $value];

                        };         
       
 if($data > 0) {

            foreach ($data as $datum) {
                $tradeID->tradereason()->save (new TradeReason($datum));
            }

        }

可以用after验证规则说收盘时间应该在进场时间之后:

public function store(Request $request)
{
    $rules = [
        'entry_dateTime' => ['required', 'date'],
        'close_dateTime' => ['required', 'date', 'after:entry_dateTime'],
    ];

    $this->validate($request, $rules);

    $input = $request->all();

    ...
}