Sending e-mails and settings on Team.

This commit is contained in:
Joao Patricio
2023-05-25 17:27:52 +01:00
parent aea6bced69
commit f23a760aac
23 changed files with 344 additions and 267 deletions

View File

@@ -2,28 +2,59 @@
namespace App\Models;
class Team extends BaseModel
use App\Notifications\Channels\SendsCoolifyEmail;
use App\Notifications\Channels\SendsDiscord;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Notifications\Notifiable;
use Spatie\SchemalessAttributes\Casts\SchemalessAttributes;
class Team extends BaseModel implements SendsDiscord, SendsCoolifyEmail
{
use Notifiable;
protected $casts = [
'extra_attributes' => SchemalessAttributes::class,
'personal_team' => 'boolean',
];
protected $fillable = [
'id',
'name',
'personal_team'
'personal_team',
'extra_attributes',
];
public function routeNotificationForDiscord()
{
return $this->extra_attributes->get('discord_webhook');
}
public function routeNotificationForCoolifyEmail()
{
$recipients = $this->extra_attributes->get('recipients', '');
return explode(PHP_EOL, $recipients);
}
public function scopeWithExtraAttributes(): Builder
{
return $this->extra_attributes->modelScope();
}
public function projects()
{
return $this->hasMany(Project::class);
}
public function servers()
{
return $this->hasMany(Server::class);
}
public function applications()
{
return $this->hasManyThrough(Application::class, Project::class);
}
public function privateKeys()
{
return $this->hasMany(PrivateKey::class);