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,10 +2,12 @@
namespace App\Models;
use Exception;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\SoftDeletes;
use Throwable;
class StandaloneMongodb extends BaseModel
{
@@ -18,7 +20,7 @@ class StandaloneMongodb extends BaseModel
protected static function booted()
{
static::created(function ($database) {
LocalPersistentVolume::create([
LocalPersistentVolume::query()->create([
'name' => 'mongodb-configdb-'.$database->uuid,
'mount_path' => '/data/configdb',
'host_path' => null,
@@ -26,7 +28,7 @@ class StandaloneMongodb extends BaseModel
'resource_type' => $database->getMorphClass(),
'is_readonly' => true,
]);
LocalPersistentVolume::create([
LocalPersistentVolume::query()->create([
'name' => 'mongodb-db-'.$database->uuid,
'mount_path' => '/data/db',
'host_path' => null,
@@ -73,14 +75,13 @@ class StandaloneMongodb extends BaseModel
}
if ($oldConfigHash === $newConfigHash) {
return false;
} else {
if ($save) {
$this->config_hash = $newConfigHash;
$this->save();
}
return true;
}
if ($save) {
$this->config_hash = $newConfigHash;
$this->save();
}
return true;
}
public function isRunning()
@@ -113,8 +114,8 @@ class StandaloneMongodb extends BaseModel
return;
}
$server = data_get($this, 'destination.server');
foreach ($persistentStorages as $storage) {
instant_remote_process(["docker volume rm -f $storage->name"], $server, false);
foreach ($persistentStorages as $persistentStorage) {
instant_remote_process(["docker volume rm -f $persistentStorage->name"], $server, false);
}
}
@@ -196,7 +197,7 @@ class StandaloneMongodb extends BaseModel
get: function ($value) {
try {
return decrypt($value);
} catch (\Throwable $th) {
} catch (Throwable $th) {
$this->mongo_initdb_root_password = encrypt($value);
$this->save();
@@ -297,7 +298,7 @@ class StandaloneMongodb extends BaseModel
if ($error === 'Unauthorized') {
$error = 'Unauthorized, please check your metrics token or restart Sentinel to set a new token.';
}
throw new \Exception($error);
throw new Exception($error);
}
$metrics = json_decode($metrics, true);
$parsedCollection = collect($metrics)->map(function ($metric) {
@@ -319,7 +320,7 @@ class StandaloneMongodb extends BaseModel
if ($error === 'Unauthorized') {
$error = 'Unauthorized, please check your metrics token or restart Sentinel to set a new token.';
}
throw new \Exception($error);
throw new Exception($error);
}
$metrics = json_decode($metrics, true);
$parsedCollection = collect($metrics)->map(function ($metric) {