coolify/app/Models/GithubApp.php

28 lines
822 B
PHP
Raw Normal View History

2023-03-28 12:09:34 +02:00
<?php
namespace App\Models;
class GithubApp extends BaseModel
{
2023-05-08 13:36:49 +02:00
protected $fillable = ['name', 'organization', 'api_url', 'html_url', 'custom_user', 'custom_port', 'team_id'];
2023-04-19 14:00:31 +02:00
protected $casts = [
'is_public' => 'boolean',
];
2023-03-28 12:09:34 +02:00
public function applications()
{
return $this->morphMany(Application::class, 'source');
}
public function privateKey()
{
return $this->belongsTo(PrivateKey::class);
}
2023-05-08 11:51:03 +02:00
static public function public()
{
return GithubApp::where('team_id', session('currentTeam')->id)->where('is_public', true)->get();
}
static public function private()
{
2023-05-08 21:56:44 +02:00
return GithubApp::where('team_id', session('currentTeam')->id)->where('is_public', false)->whereNotNull('app_id')->whereNotNull('installation_id')->get();
2023-05-08 11:51:03 +02:00
}
2023-03-28 12:09:34 +02:00
}