mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-02 22:46:16 +00:00
Add phpstan level 7(#544)
This commit is contained in:
@ -26,18 +26,19 @@
|
||||
* @property string $profile_photo_path
|
||||
* @property string $two_factor_recovery_codes
|
||||
* @property string $two_factor_secret
|
||||
* @property SshKey[] $sshKeys
|
||||
* @property SourceControl[] $sourceControls
|
||||
* @property ServerProvider[] $serverProviders
|
||||
* @property Script[] $scripts
|
||||
* @property StorageProvider[] $storageProviders
|
||||
* @property StorageProvider[] $connectedStorageProviders
|
||||
* @property Collection $tokens
|
||||
* @property Collection<int, SshKey> $sshKeys
|
||||
* @property Collection<int, SourceControl> $sourceControls
|
||||
* @property Collection<int, ServerProvider> $serverProviders
|
||||
* @property Collection<int, Server> $servers
|
||||
* @property Collection<int, Script> $scripts
|
||||
* @property Collection<int, StorageProvider> $storageProviders
|
||||
* @property Collection<int, StorageProvider> $connectedStorageProviders
|
||||
* @property Collection<int, PersonalAccessToken> $tokens
|
||||
* @property string $profile_photo_url
|
||||
* @property string $timezone
|
||||
* @property int $current_project_id
|
||||
* @property Project $currentProject
|
||||
* @property Collection<Project> $projects
|
||||
* @property ?int $current_project_id
|
||||
* @property ?Project $currentProject
|
||||
* @property Collection<int, Project> $projects
|
||||
* @property string $role
|
||||
* @property Carbon $created_at
|
||||
* @property Carbon $updated_at
|
||||
@ -45,7 +46,10 @@
|
||||
class User extends Authenticatable implements FilamentUser
|
||||
{
|
||||
use HasApiTokens;
|
||||
|
||||
/** @use HasFactory<\Database\Factories\UserFactory> */
|
||||
use HasFactory;
|
||||
|
||||
use HasTimezoneTimestamps;
|
||||
use Notifiable;
|
||||
use TwoFactorAuthenticatable;
|
||||
@ -69,41 +73,65 @@ class User extends Authenticatable implements FilamentUser
|
||||
protected $appends = [
|
||||
];
|
||||
|
||||
/**
|
||||
* @return HasMany<Server, covariant $this>
|
||||
*/
|
||||
public function servers(): HasMany
|
||||
{
|
||||
return $this->hasMany(Server::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany<SshKey, covariant $this>
|
||||
*/
|
||||
public function sshKeys(): HasMany
|
||||
{
|
||||
return $this->hasMany(SshKey::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany<SourceControl, covariant $this>
|
||||
*/
|
||||
public function sourceControls(): HasMany
|
||||
{
|
||||
return $this->hasMany(SourceControl::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany<ServerProvider, covariant $this>
|
||||
*/
|
||||
public function serverProviders(): HasMany
|
||||
{
|
||||
return $this->hasMany(ServerProvider::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasOne<SourceControl, covariant $this>
|
||||
*/
|
||||
public function sourceControl(string $provider): HasOne
|
||||
{
|
||||
return $this->hasOne(SourceControl::class)->where('provider', $provider);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany<StorageProvider, covariant $this>
|
||||
*/
|
||||
public function storageProviders(): HasMany
|
||||
{
|
||||
return $this->hasMany(StorageProvider::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasOne<StorageProvider, covariant $this>
|
||||
*/
|
||||
public function storageProvider(string $provider): HasOne
|
||||
{
|
||||
return $this->hasOne(StorageProvider::class)->where('provider', $provider);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Builder<Project>|BelongsToMany<Project, covariant $this>
|
||||
*/
|
||||
public function allProjects(): Builder|BelongsToMany
|
||||
{
|
||||
if ($this->isAdmin()) {
|
||||
@ -113,12 +141,18 @@ public function allProjects(): Builder|BelongsToMany
|
||||
return $this->projects();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsToMany<Project, covariant $this>
|
||||
*/
|
||||
public function projects(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Project::class, 'user_project')
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasOne<Project, covariant $this>
|
||||
*/
|
||||
public function currentProject(): HasOne
|
||||
{
|
||||
return $this->HasOne(Project::class, 'id', 'current_project_id');
|
||||
@ -126,6 +160,7 @@ public function currentProject(): HasOne
|
||||
|
||||
public function createDefaultProject(): Project
|
||||
{
|
||||
/** @var ?Project $project */
|
||||
$project = $this->projects()->first();
|
||||
|
||||
if (! $project) {
|
||||
@ -147,15 +182,24 @@ public function isAdmin(): bool
|
||||
return $this->role === UserRole::ADMIN;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany<Script, covariant $this>
|
||||
*/
|
||||
public function scripts(): HasMany
|
||||
{
|
||||
return $this->hasMany(Script::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Builder<Server>
|
||||
*/
|
||||
public function allServers(): Builder
|
||||
{
|
||||
return Server::query()->whereHas('project', function (Builder $query) {
|
||||
$query->whereHas('users', function ($query) {
|
||||
/** @var Builder<Server> $query */
|
||||
$query = Server::query();
|
||||
|
||||
return $query->whereHas('project', function (Builder $query): void {
|
||||
$query->whereHas('users', function ($query): void {
|
||||
$query->where('user_id', $this->id);
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user