user(); return [ 'entity' => 'bail|required|string|in:invoice,quote,credit,recurring_invoice,purchase_order', 'entity_id' => ['bail','required',Rule::exists($this->entity_plural, 'id')->where('company_id', $user->company()->id)], ]; } public function prepareForValidation() { $input = $this->all(); $this->entity_plural = Str::plural($input['entity']) ?? ''; $input['entity_id'] = $this->decodePrimaryKey($input['entity_id']); $this->replace($input); } }