a lot hehe

This commit is contained in:
Andras Bacsai
2023-06-01 12:15:33 +02:00
parent c8f70a4e3b
commit 0aa816b4f2
42 changed files with 570 additions and 249 deletions

View File

@@ -22,16 +22,23 @@ class Server extends BaseModel
'port',
'team_id',
'private_key_id',
'extra_attributes',
'smtp_attributes',
];
public $casts = [
'extra_attributes' => SchemalessAttributes::class,
'smtp_attributes' => SchemalessAttributes::class,
];
public function scopeWithExtraAttributes(): Builder
{
return $this->extra_attributes->modelScope();
}
public function scopeWithSmtpAttributes(): Builder
{
return $this->smtp_attributes->modelScope();
}
public function standaloneDockers()
{
@@ -43,8 +50,6 @@ class Server extends BaseModel
return $this->hasMany(SwarmDocker::class);
}
public function privateKey()
{
return $this->belongsTo(PrivateKey::class);

View File

@@ -2,42 +2,41 @@
namespace App\Models;
use App\Notifications\Channels\SendsCoolifyEmail;
use App\Notifications\Channels\SendsEmail;
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
class Team extends BaseModel implements SendsDiscord, SendsEmail
{
use Notifiable;
protected $casts = [
'extra_attributes' => SchemalessAttributes::class,
'smtp_attributes' => SchemalessAttributes::class,
'personal_team' => 'boolean',
];
protected $fillable = [
'id',
'name',
'personal_team',
'extra_attributes',
'smtp_attributes',
];
public function routeNotificationForDiscord()
{
return $this->extra_attributes->get('discord_webhook');
return $this->smtp_attributes->get('discord_webhook');
}
public function routeNotificationForCoolifyEmail()
public function routeNotificationForEmail(string $attribute = 'recipients')
{
$recipients = $this->extra_attributes->get('recipients', '');
$recipients = $this->smtp_attributes->get($attribute, '');
return explode(PHP_EOL, $recipients);
}
public function scopeWithExtraAttributes(): Builder
{
return $this->extra_attributes->modelScope();
return $this->smtp_attributes->modelScope();
}
public function projects()

View File

@@ -8,10 +8,11 @@ use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;
use Visus\Cuid2\Cuid2;
use Laravel\Fortify\TwoFactorAuthenticatable;
class User extends Authenticatable
{
use HasApiTokens, HasFactory, Notifiable;
use HasApiTokens, HasFactory, Notifiable, TwoFactorAuthenticatable;
protected $fillable = [
'id',
'name',