wip: boarding

This commit is contained in:
Andras Bacsai
2023-08-22 17:44:49 +02:00
parent 2414ddd360
commit b39ca51d41
71 changed files with 694 additions and 137 deletions

View File

@@ -41,7 +41,7 @@ class EnvironmentVariable extends Model
private function get_environment_variables(string $environment_variable): string|null
{
// $team_id = auth()->user()->currentTeam()->id;
// $team_id = currentTeam()->id;
if (str_contains(trim($environment_variable), '{{') && str_contains(trim($environment_variable), '}}')) {
$environment_variable = preg_replace('/\s+/', '', $environment_variable);
$environment_variable = str_replace('{{', '', $environment_variable);

View File

@@ -19,12 +19,12 @@ class GithubApp extends BaseModel
static public function public()
{
return GithubApp::whereTeamId(auth()->user()->currentTeam()->id)->whereisPublic(true)->whereNotNull('app_id')->get();
return GithubApp::whereTeamId(currentTeam()->id)->whereisPublic(true)->whereNotNull('app_id')->get();
}
static public function private()
{
return GithubApp::whereTeamId(auth()->user()->currentTeam()->id)->whereisPublic(false)->whereNotNull('app_id')->get();
return GithubApp::whereTeamId(currentTeam()->id)->whereisPublic(false)->whereNotNull('app_id')->get();
}
protected static function booted(): void

View File

@@ -16,7 +16,7 @@ class PrivateKey extends BaseModel
static public function ownedByCurrentTeam(array $select = ['*'])
{
$selectArray = collect($select)->concat(['id']);
return PrivateKey::whereTeamId(auth()->user()->currentTeam()->id)->select($selectArray->all());
return PrivateKey::whereTeamId(currentTeam()->id)->select($selectArray->all());
}
public function isEmpty()

View File

@@ -4,16 +4,11 @@ namespace App\Models;
class Project extends BaseModel
{
protected $fillable = [
'name',
'description',
'team_id',
'project_id'
];
protected $guarded = [];
static public function ownedByCurrentTeam()
{
return Project::whereTeamId(auth()->user()->currentTeam()->id)->orderBy('name');
return Project::whereTeamId(currentTeam()->id)->orderBy('name');
}
protected static function booted()

View File

@@ -17,7 +17,7 @@ class S3Storage extends BaseModel
static public function ownedByCurrentTeam(array $select = ['*'])
{
$selectArray = collect($select)->concat(['id']);
return S3Storage::whereTeamId(auth()->user()->currentTeam()->id)->select($selectArray->all())->orderBy('name');
return S3Storage::whereTeamId(currentTeam()->id)->select($selectArray->all())->orderBy('name');
}
public function awsUrl()

View File

@@ -33,7 +33,7 @@ class Server extends BaseModel
static public function ownedByCurrentTeam(array $select = ['*'])
{
$teamId = auth()->user()->currentTeam()->id;
$teamId = currentTeam()->id;
$selectArray = collect($select)->concat(['id']);
return Server::whereTeamId($teamId)->with('settings')->select($selectArray->all())->orderBy('name');
}

View File

@@ -22,6 +22,7 @@ class User extends Authenticatable implements SendsEmail
protected $casts = [
'email_verified_at' => 'datetime',
'force_password_reset' => 'boolean',
'show_boarding' => 'boolean',
];
protected static function boot()
@@ -31,6 +32,7 @@ class User extends Authenticatable implements SendsEmail
$team = [
'name' => $user->name . "'s Team",
'personal_team' => true,
'show_boarding' => true,
];
if ($user->id === 0) {
$team['id'] = 0;
@@ -102,7 +104,7 @@ class User extends Authenticatable implements SendsEmail
public function otherTeams()
{
$team_id = auth()->user()->currentTeam()->id;
$team_id = currentTeam()->id;
return auth()->user()->teams->filter(function ($team) use ($team_id) {
return $team->id != $team_id;
});
@@ -113,13 +115,6 @@ class User extends Authenticatable implements SendsEmail
if ($this->teams()->where('team_id', 0)->first()) {
return 'admin';
}
return $this->teams()->where('team_id', auth()->user()->currentTeam()->id)->first()->pivot->role;
}
public function resources()
{
$team_id = auth()->user()->currentTeam()->id;
$data = Application::where('team_id', $team_id)->get();
return $data;
return $this->teams()->where('team_id', currentTeam()->id)->first()->pivot->role;
}
}