Implement Gitea user connection foundation
This commit is contained in:
@@ -8,6 +8,7 @@ use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Attributes\Hidden;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Laravel\Fortify\TwoFactorAuthenticatable;
|
||||
@@ -39,4 +40,11 @@ class User extends Authenticatable
|
||||
return $this->belongsToMany(Team::class)
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
public function gitConnections(): HasMany
|
||||
{
|
||||
return $this->hasMany(UserGitConnection::class)
|
||||
->orderBy('provider')
|
||||
->orderBy('base_url');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Actions\Git\GitProviderKey;
|
||||
use Database\Factories\UserGitConnectionFactory;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Attributes\Hidden;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
#[Fillable([
|
||||
'account_login',
|
||||
'account_name',
|
||||
'api_token',
|
||||
'base_url',
|
||||
'provider',
|
||||
'provider_user_id',
|
||||
'user_id',
|
||||
])]
|
||||
#[Hidden(['api_token'])]
|
||||
class UserGitConnection extends Model
|
||||
{
|
||||
/** @use HasFactory<UserGitConnectionFactory> */
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'api_token' => 'encrypted',
|
||||
'provider' => GitProviderKey::class,
|
||||
];
|
||||
}
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user