feat: add is shared to env variables
This commit is contained in:
@@ -74,6 +74,9 @@ class EnvironmentVariable extends Model
|
|||||||
'version' => config('version'),
|
'version' => config('version'),
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
static::saving(function (EnvironmentVariable $environmentVariable) {
|
||||||
|
$environmentVariable->updateIsShared();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function service()
|
public function service()
|
||||||
@@ -217,4 +220,11 @@ class EnvironmentVariable extends Model
|
|||||||
set: fn (string $value) => str($value)->trim()->replace(' ', '_')->value,
|
set: fn (string $value) => str($value)->trim()->replace(' ', '_')->value,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function updateIsShared(): void
|
||||||
|
{
|
||||||
|
$type = str($this->value)->after('{{')->before('.')->value;
|
||||||
|
$isShared = str($this->value)->startsWith('{{'.$type) && str($this->value)->endsWith('}}');
|
||||||
|
$this->is_shared = $isShared;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class AddIsSharedToEnvironmentVariables extends Migration
|
||||||
|
{
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('environment_variables', function (Blueprint $table) {
|
||||||
|
$table->boolean('is_shared')->default(false);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('environment_variables', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('is_shared');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user