2025-10-08 18:47:50 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
2025-12-10 07:59:13 +00:00
|
|
|
class CloudProviderToken extends BaseModel
|
2025-10-08 18:47:50 +00:00
|
|
|
{
|
|
|
|
|
protected $guarded = [];
|
|
|
|
|
|
|
|
|
|
protected $casts = [
|
|
|
|
|
'token' => 'encrypted',
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
public function team()
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsTo(Team::class);
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-09 10:53:57 +00:00
|
|
|
public function servers()
|
|
|
|
|
{
|
|
|
|
|
return $this->hasMany(Server::class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function hasServers(): bool
|
|
|
|
|
{
|
|
|
|
|
return $this->servers()->exists();
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-08 18:47:50 +00:00
|
|
|
public static function ownedByCurrentTeam(array $select = ['*'])
|
|
|
|
|
{
|
|
|
|
|
$selectArray = collect($select)->concat(['id']);
|
|
|
|
|
|
|
|
|
|
return self::whereTeamId(currentTeam()->id)->select($selectArray->all());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function scopeForProvider($query, string $provider)
|
|
|
|
|
{
|
|
|
|
|
return $query->where('provider', $provider);
|
|
|
|
|
}
|
|
|
|
|
}
|