global storage-providers, notification channels and server providers (#247)

This commit is contained in:
Saeed Vaziry
2024-06-29 12:52:03 +03:30
committed by GitHub
parent ad027eb033
commit 11e3b167cc
44 changed files with 678 additions and 77 deletions

View File

@ -2,6 +2,7 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
@ -13,6 +14,7 @@
* @property array $credentials
* @property bool $connected
* @property User $user
* @property ?int $project_id
*/
class ServerProvider extends AbstractModel
{
@ -24,12 +26,14 @@ class ServerProvider extends AbstractModel
'provider',
'credentials',
'connected',
'project_id',
];
protected $casts = [
'user_id' => 'integer',
'credentials' => 'encrypted:array',
'connected' => 'boolean',
'project_id' => 'integer',
];
public function user(): BelongsTo
@ -46,4 +50,16 @@ public function servers(): HasMany
{
return $this->hasMany(Server::class, 'provider_id');
}
public function project(): BelongsTo
{
return $this->belongsTo(Project::class);
}
public static function getByProjectId(int $projectId): Builder
{
return self::query()
->where('project_id', $projectId)
->orWhereNull('project_id');
}
}