chore(core): EnvironmentVariable Model now extends BaseModel to remove duplicated code
This commit is contained in:
parent
e155f3905b
commit
3f2f1cf966
1 changed files with 1 additions and 9 deletions
|
|
@ -4,9 +4,7 @@
|
||||||
|
|
||||||
use App\Models\EnvironmentVariable as ModelsEnvironmentVariable;
|
use App\Models\EnvironmentVariable as ModelsEnvironmentVariable;
|
||||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
|
||||||
use OpenApi\Attributes as OA;
|
use OpenApi\Attributes as OA;
|
||||||
use Visus\Cuid2\Cuid2;
|
|
||||||
|
|
||||||
#[OA\Schema(
|
#[OA\Schema(
|
||||||
description: 'Environment Variable model',
|
description: 'Environment Variable model',
|
||||||
|
|
@ -30,7 +28,7 @@
|
||||||
'updated_at' => ['type' => 'string'],
|
'updated_at' => ['type' => 'string'],
|
||||||
]
|
]
|
||||||
)]
|
)]
|
||||||
class EnvironmentVariable extends Model
|
class EnvironmentVariable extends BaseModel
|
||||||
{
|
{
|
||||||
protected $guarded = [];
|
protected $guarded = [];
|
||||||
|
|
||||||
|
|
@ -49,12 +47,6 @@ class EnvironmentVariable extends Model
|
||||||
|
|
||||||
protected static function booted()
|
protected static function booted()
|
||||||
{
|
{
|
||||||
static::creating(function (Model $model) {
|
|
||||||
if (! $model->uuid) {
|
|
||||||
$model->uuid = (string) new Cuid2;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
static::created(function (EnvironmentVariable $environment_variable) {
|
static::created(function (EnvironmentVariable $environment_variable) {
|
||||||
if ($environment_variable->resourceable_type === Application::class && ! $environment_variable->is_preview) {
|
if ($environment_variable->resourceable_type === Application::class && ! $environment_variable->is_preview) {
|
||||||
$found = ModelsEnvironmentVariable::where('key', $environment_variable->key)
|
$found = ModelsEnvironmentVariable::where('key', $environment_variable->key)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue