rector: arrrrr

This commit is contained in:
Andras Bacsai
2025-01-07 14:52:08 +01:00
parent c702ebff6d
commit 16c0cd10d8
349 changed files with 4204 additions and 3712 deletions

View File

@@ -2,6 +2,7 @@
namespace App\Models;
use Exception;
use Illuminate\Database\Eloquent\Casts\Attribute;
class GithubApp extends BaseModel
@@ -10,11 +11,6 @@ class GithubApp extends BaseModel
protected $appends = ['type'];
protected $casts = [
'is_public' => 'boolean',
'type' => 'string',
];
protected $hidden = [
'client_secret',
'webhook_secret',
@@ -22,12 +18,12 @@ class GithubApp extends BaseModel
protected static function booted(): void
{
static::deleting(function (GithubApp $github_app) {
$applications_count = Application::where('source_id', $github_app->id)->count();
static::deleting(function (GithubApp $githubApp) {
$applications_count = Application::query()->where('source_id', $githubApp->id)->count();
if ($applications_count > 0) {
throw new \Exception('You cannot delete this GitHub App because it is in use by '.$applications_count.' application(s). Delete them first.');
throw new Exception('You cannot delete this GitHub App because it is in use by '.$applications_count.' application(s). Delete them first.');
}
$github_app->privateKey()->delete();
$githubApp->privateKey()->delete();
});
}
@@ -71,4 +67,12 @@ class GithubApp extends BaseModel
},
);
}
protected function casts(): array
{
return [
'is_public' => 'boolean',
'type' => 'string',
];
}
}