mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Fix sensor state translations (#16393)
* Fix sensor state translations * Fix up lint/style * Set state_index_id * Apply fixes from StyleCI * Wrong call * just use a loop * Wrong id column * Missing fillable * Handle sensors missing state translations * Before making a state index * Can't map to a state index if it doesn't exist * Apply fixes from StyleCI * ies5000 overflowing tinyint * Accept state translations directly add that in the translation * handle duplicate state names, but with different case (skip no way to work there) * Apply fixes from StyleCI * Fix type stuffs --------- Co-authored-by: Tony Murray <murrant@users.noreply.github.com>
This commit is contained in:
@@ -4,6 +4,7 @@ namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOneThrough;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
use LibreNMS\Interfaces\Models\Keyable;
|
||||
|
||||
@@ -129,9 +130,14 @@ class Sensor extends DeviceRelatedModel implements Keyable
|
||||
return $this->morphMany(Eventlog::class, 'events', 'type', 'reference');
|
||||
}
|
||||
|
||||
public function stateIndex(): HasOneThrough
|
||||
{
|
||||
return $this->hasOneThrough(StateIndex::class, SensorToStateIndex::class, 'sensor_id', 'state_index_id', 'sensor_id', 'state_index_id');
|
||||
}
|
||||
|
||||
public function translations(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(StateTranslation::class, 'sensors_to_state_indexes', 'sensor_id', 'state_index_id');
|
||||
return $this->belongsToMany(StateTranslation::class, 'sensors_to_state_indexes', 'sensor_id', 'state_index_id', 'sensor_id', 'state_index_id');
|
||||
}
|
||||
|
||||
public function getCompositeKey(): string
|
||||
|
||||
Reference in New Issue
Block a user