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;
@ -12,6 +13,7 @@
* @property string $provider
* @property array $credentials
* @property User $user
* @property int $project_id
*/
class StorageProvider extends AbstractModel
{
@ -22,11 +24,13 @@ class StorageProvider extends AbstractModel
'profile',
'provider',
'credentials',
'project_id',
];
protected $casts = [
'user_id' => 'integer',
'credentials' => 'encrypted:array',
'project_id' => 'integer',
];
public function user(): BelongsTo
@ -45,4 +49,16 @@ public function backups(): HasMany
{
return $this->hasMany(Backup::class, 'storage_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');
}
}