*/ public function rules(): array { $free = Rule::unique('units')->where('company_id', $this->header('company')); // Quirk kept as is: only PUT excuses the edited row from the name // check. A PATCH would collide with its own stored name. if ($this->isMethod('PUT')) { $free->ignore($this->route('unit'), 'id'); } return [ 'name' => ['required', $free], ]; } /** * The validated attributes with the acting company folded in, ready to be * written to a unit. * * @return array */ public function getUnitPayload() { return array_merge($this->validated(), [ 'company_id' => $this->header('company'), ]); } }