*/ public function postRules() { return [ 'code' => 'required|string|max:255|min:2|unique:shortlinks', 'url' => 'required|string|max:255|min:2', ]; } /** * Get the validation rules that apply to PUT request. * * @return array */ public function putRules() { $shortlink = $this->route('shortlink'); return [ 'code' => ['required', 'string', 'max:255', 'min:2', Rule::unique('shortlinks')->ignore($shortlink->id)], 'url' => 'required|string|max:255|min:2', ]; } }