Is there any way to validate required field when the requested url contains some parameter?
2条回答 默认 最新
- douwo5710 2018-10-05 17:49关注
Assuming you are using Form requsts, you can simple use PHP condition.
public function rules() { $rules = []; // here you put some rules // here you check condition and add some rule when it's true if (str_contains($this->input('url'), 'something')) { $rules['some_other_field'] = 'required'; } return $rules; }
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报