public function byType($type)
{
$setting = $this->model->where('type', $type)->first();
if (!is_null($setting)) {
return $setting;
}
if ($type === 'mail') {
$attributes = new MailSettingEntity();
$attributes->setDriver('smtp');
$attributes->setFrom(['address' => '[email protected]', 'name' => 'Webloyer']);
$attributes->setSmtpHost('smtp.mailgun.org');
$attributes->setSmtpPort(587);
$attributes->setSmtpEncryption('tls');
$attributes->setSendmailPath('/usr/sbin/sendmail -bs');
}
return $this->model->create(['type' => $type, 'attributes' => $attributes]);
}