[ 'required', Rule::unique('mail_senders') ->where('company_id', $this->header('company')) ], 'driver' => [ 'required', ], 'is_default' => [ 'nullable' ], 'bcc' => [ 'nullable' ], 'cc' => [ 'nullable' ], 'from_address' => [ 'nullable' ], 'from_name' => [ 'nullable' ], 'settings' => [ 'nullable' ], 'settings.*' => [ 'nullable' ] ]; if ($this->isMethod('PUT')) { $rules['name'] = [ 'nullable', Rule::unique('mail_senders') ->ignore($this->route('mail_sender')->id) ->where('company_id', $this->header('company')) ]; } return $rules; } public function getMailSenderPayload() { return collect($this->validated()) ->merge([ 'company_id' => $this->header('company'), ]) ->toArray(); } }