mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-01 05:56:16 +00:00
source-controls (#193)
* edit source control * assign project after creation * global and project scoped source controls
This commit is contained in:
@ -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();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user