mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-01 05:56:16 +00:00
init
This commit is contained in:
36
app/Models/SourceControl.php
Executable file
36
app/Models/SourceControl.php
Executable file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Contracts\SourceControlProvider;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
/**
|
||||
* @property string $provider
|
||||
* @property string $access_token
|
||||
*/
|
||||
class SourceControl extends AbstractModel
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'provider',
|
||||
'access_token',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'access_token' => 'encrypted',
|
||||
];
|
||||
|
||||
public function provider(): SourceControlProvider
|
||||
{
|
||||
$providerClass = config('core.source_control_providers_class')[$this->provider];
|
||||
|
||||
return new $providerClass($this);
|
||||
}
|
||||
|
||||
public function getRepo(string $repo = null): ?array
|
||||
{
|
||||
return $this->provider()->getRepo($repo);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user