/** * Get the validation rules that apply to the request. * * @return array */ public function rules() { // Instead of using the 'exists' validation rule, we opt to use // the 'in' rule. We do this because we want to add '0' as a valid // value, which will signal a wild card for either all characters // or all corporations. $character_ids = implode(',', array_prepend(ApiKeyInfoCharacters::pluck('characterID')->toArray(), 0)); $corporation_ids = implode(',', array_prepend(CorporationSheet::pluck('corporationID')->toArray(), 0)); return ['id' => 'required|numeric|exists:notification_groups,id', 'characters' => 'required_without_all:corporations', 'corporations' => 'required_without_all:characters', 'characters.*' => 'in:' . $character_ids, 'corporations.*' => 'in:' . $corporation_ids]; }