bug - Component "error" length issue (#15918)

* truncate component error in F5 LTM code

* sanity check in COmponent

* style

* mutators

* mutators moved

* moving

* Mutators OK, removing check from F5

* style

* fix LibreNMS/Component.php

* remove protected and see if it fixes issues

* nullable

* nullable

* nullable
This commit is contained in:
PipoCanaja
2024-08-25 23:32:59 +02:00
committed by GitHub
parent 3dd4084404
commit 2face4bc4a

View File

@@ -25,6 +25,7 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\HasMany;
@@ -53,6 +54,27 @@ class Component extends DeviceRelatedModel
$this->attributes['ignore'] = (int) $ignore;
}
public function error(): Attribute
{
return Attribute::make(
set: fn (?string $value) => is_null($value) ? null : substr($value, 0, 255),
);
}
public function label(): Attribute
{
return Attribute::make(
set: fn (?string $value) => is_null($value) ? null : substr($value, 0, 255),
);
}
public function type(): Attribute
{
return Attribute::make(
set: fn (?string $value) => is_null($value) ? null : substr($value, 0, 50),
);
}
// ---- Define Relationships ----
public function logs(): HasMany