source-controls (#193)

* edit source control
* assign project after creation
* global and project scoped source controls
This commit is contained in:
Saeed Vaziry
2024-05-08 00:07:11 +02:00
committed by GitHub
parent e704a13d6b
commit 179aefefac
15 changed files with 362 additions and 10 deletions

View File

@ -3,7 +3,9 @@
namespace App\Models;
use App\SourceControlProviders\SourceControlProvider;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
/**
@ -12,6 +14,7 @@
* @property ?string $profile
* @property ?string $url
* @property string $access_token
* @property ?int $project_id
*/
class SourceControl extends AbstractModel
{
@ -23,11 +26,13 @@ class SourceControl extends AbstractModel
'profile',
'url',
'access_token',
'project_id',
];
protected $casts = [
'access_token' => 'encrypted',
'provider_data' => 'encrypted:array',
'project_id' => 'integer',
];
public function provider(): SourceControlProvider
@ -46,4 +51,16 @@ public function sites(): HasMany
{
return $this->hasMany(Site::class);
}
public function project(): BelongsTo
{
return $this->belongsTo(Project::class);
}
public static function getByCurrentProject(): Collection
{
return self::query()
->where('project_id', auth()->user()->current_project_id)
->orWhereNull('project_id')->get();
}
}