rector: arrrrr

This commit is contained in:
Andras Bacsai
2025-01-07 14:52:08 +01:00
parent c702ebff6d
commit 16c0cd10d8
349 changed files with 4204 additions and 3712 deletions

View File

@@ -8,6 +8,7 @@ use App\Notifications\Channels\SendsEmail;
use App\Notifications\Channels\SendsPushover;
use App\Notifications\Channels\SendsSlack;
use App\Traits\HasNotificationSettings;
use Exception;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Notifications\Notifiable;
@@ -40,10 +41,6 @@ class Team extends Model implements SendsDiscord, SendsEmail, SendsPushover, Sen
protected $guarded = [];
protected $casts = [
'personal_team' => 'boolean',
];
protected static function booted()
{
static::created(function ($team) {
@@ -56,7 +53,7 @@ class Team extends Model implements SendsDiscord, SendsEmail, SendsPushover, Sen
static::saving(function ($team) {
if (auth()->user()?->isMember()) {
throw new \Exception('You are not allowed to update this team.');
throw new Exception('You are not allowed to update this team.');
}
});
@@ -95,11 +92,7 @@ class Team extends Model implements SendsDiscord, SendsEmail, SendsPushover, Sen
public function serverOverflow()
{
if ($this->serverLimit() < $this->servers->count()) {
return true;
}
return false;
return $this->serverLimit() < $this->servers->count();
}
public static function serverLimit()
@@ -107,7 +100,7 @@ class Team extends Model implements SendsDiscord, SendsEmail, SendsPushover, Sen
if (currentTeam()->id === 0 && isDev()) {
return 9999999;
}
$team = Team::find(currentTeam()->id);
$team = \App\Models\Team::query()->find(currentTeam()->id);
if (! $team) {
return 0;
}
@@ -169,12 +162,20 @@ class Team extends Model implements SendsDiscord, SendsEmail, SendsPushover, Sen
if (isCloud()) {
return true;
}
if ($this->getNotificationSettings('email')?->isEnabled()) {
return true;
}
if ($this->getNotificationSettings('discord')?->isEnabled()) {
return true;
}
if ($this->getNotificationSettings('slack')?->isEnabled()) {
return true;
}
if ($this->getNotificationSettings('telegram')?->isEnabled()) {
return true;
}
return $this->getNotificationSettings('email')?->isEnabled() ||
$this->getNotificationSettings('discord')?->isEnabled() ||
$this->getNotificationSettings('slack')?->isEnabled() ||
$this->getNotificationSettings('telegram')?->isEnabled() ||
$this->getNotificationSettings('pushover')?->isEnabled();
return (bool) $this->getNotificationSettings('pushover')?->isEnabled();
}
public function subscriptionEnded()
@@ -222,11 +223,7 @@ class Team extends Model implements SendsDiscord, SendsEmail, SendsPushover, Sen
public function isEmpty()
{
if ($this->projects()->count() === 0 && $this->servers()->count() === 0 && $this->privateKeys()->count() === 0 && $this->sources()->count() === 0) {
return true;
}
return false;
return $this->projects()->count() === 0 && $this->servers()->count() === 0 && $this->privateKeys()->count() === 0 && $this->sources()->count() === 0;
}
public function projects()
@@ -282,4 +279,11 @@ class Team extends Model implements SendsDiscord, SendsEmail, SendsPushover, Sen
{
return $this->hasOne(PushoverNotificationSettings::class);
}
protected function casts(): array
{
return [
'personal_team' => 'boolean',
];
}
}