lundi 25 janvier 2016

how to validate input array with a same name in laravel controller

I have a problem when a i try to insert record into table like this .

$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();
        }

I want to check start_on not equals another start_on.So what can i do?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire