How to validate Route Parameters in Laravel 5?

后端 未结 4 1593
灰色年华
灰色年华 2021-02-12 18:23

As you know Laravel 5 changes the way you call the validator, the old way is calling the validator facade, but now there is the ValidatesRequests

4条回答
  •  梦如初夏
    2021-02-12 19:09

    public function listTurns($doctor_id, $limit, $offset){
            $r = [
                'doctor_id' => $doctor_id,
                'limit' => $limit,
                'offset' => $offset,
            ];
    
            $validator = Validator::make($r, [
                'doctor_id' => 'required|numeric|min:1|exists:doctors,id',
                'limit' => 'required|numeric|min:1',
                'offset' => 'required|numeric|min:0',
            ]);
    }
    

提交回复
热议问题