where('scope', $this->header('company')); if ($this->getMethod() === 'PUT') { $name->ignore($this->route('role')->id, 'id'); } return [ 'name' => ['required', 'string', $name], 'abilities' => ['required'], 'abilities.*' => ['required'], ]; } /** * The submitted attributes, minus the abilities, stamped with the scope. * * Everything the caller sent survives the trip; the role model's own * fillable list decides what is actually written. */ public function getRolePayload() { $attributes = $this->except('abilities'); $attributes['scope'] = $this->header('company'); return $attributes; } }