2023-03-28 15:47:37 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
2023-06-06 17:50:13 +02:00
|
|
|
use App\Notifications\Channels\SendsEmail;
|
2023-11-28 12:11:03 +01:00
|
|
|
use Illuminate\Database\Eloquent\Casts\Attribute;
|
2023-03-28 15:47:37 +02:00
|
|
|
use Illuminate\Database\Eloquent\Model;
|
2023-06-06 17:50:13 +02:00
|
|
|
use Illuminate\Notifications\Notifiable;
|
2023-12-11 19:39:27 +01:00
|
|
|
use Illuminate\Support\Facades\Log;
|
2023-12-11 18:06:29 +01:00
|
|
|
use Illuminate\Support\Facades\Request;
|
2023-11-28 12:11:03 +01:00
|
|
|
use Spatie\Url\Url;
|
2023-03-28 15:47:37 +02:00
|
|
|
|
2023-06-06 17:50:13 +02:00
|
|
|
class InstanceSettings extends Model implements SendsEmail
|
2023-03-28 15:47:37 +02:00
|
|
|
{
|
2023-07-27 21:26:15 +02:00
|
|
|
use Notifiable;
|
2023-08-08 11:51:36 +02:00
|
|
|
|
2023-07-14 11:27:08 +02:00
|
|
|
protected $guarded = [];
|
2023-06-06 17:50:13 +02:00
|
|
|
protected $casts = [
|
2023-07-14 12:09:56 +02:00
|
|
|
'resale_license' => 'encrypted',
|
2023-08-31 13:10:39 +02:00
|
|
|
'smtp_password' => 'encrypted',
|
2023-06-06 17:50:13 +02:00
|
|
|
];
|
2023-08-08 11:51:36 +02:00
|
|
|
|
2023-11-28 12:11:03 +01:00
|
|
|
public function fqdn(): Attribute
|
|
|
|
{
|
|
|
|
return Attribute::make(
|
|
|
|
set: function ($value) {
|
|
|
|
if ($value) {
|
|
|
|
$url = Url::fromString($value);
|
|
|
|
$host = $url->getHost();
|
|
|
|
return $url->getScheme() . '://' . $host;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
2023-08-08 11:51:36 +02:00
|
|
|
public static function get()
|
|
|
|
{
|
|
|
|
return InstanceSettings::findOrFail(0);
|
|
|
|
}
|
|
|
|
|
2023-07-28 10:55:26 +02:00
|
|
|
public function getRecepients($notification)
|
2023-06-06 17:50:13 +02:00
|
|
|
{
|
2023-08-08 11:51:36 +02:00
|
|
|
$recipients = data_get($notification, 'emails', null);
|
2023-06-06 17:50:13 +02:00
|
|
|
if (is_null($recipients) || $recipients === '') {
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
return explode(',', $recipients);
|
|
|
|
}
|
2023-08-08 11:51:36 +02:00
|
|
|
}
|