如何在laravel控制器中验证具有相同名称的输入数组

时间:2016-01-25 15:14:44

标签: laravel-5.1

当我尝试将记录插入这样的表格时,我遇到了问题。

$data = array();

foreach($input['user_id'] as $key => $user_id) {
    $data[$key]['user_id'] = $user_id;
}
foreach($input['start_on'] as $key => $start_on) {
    $data[$key]['start_on'] = $start_on;
}
$this->validate($request, [
    'time_start' => 'required|date',
    'time_end' => 'required|date|after:time_start',
]);
$rules = [
    'start_on' => 'required|date|after:time_start|before:time_end|different:start_on'
];

// Iterate and validate each question
foreach ($data as $value)
{
    $validator = Validator::make( $value, $rules );

    // if ($validator->fails()) return $validator->messages()->all();
}

我想检查start_on不等于另一个start_on。我该怎么办?

0 个答案:

没有答案