Files
librenms-librenms/app/Models/Sensor.php
T

69 lines
1.8 KiB
PHP
Raw Normal View History

2018-05-09 08:05:17 -05:00
<?php
namespace App\Models;
2019-01-22 17:04:28 -06:00
class Sensor extends DeviceRelatedModel
2018-05-09 08:05:17 -05:00
{
public $timestamps = false;
protected $primaryKey = 'sensor_id';
2018-05-09 08:05:17 -05:00
protected static $icons = array(
2019-01-20 13:37:08 -06:00
'airflow' => 'angle-double-right',
'ber' => 'sort-amount-desc',
2018-05-09 08:05:17 -05:00
'charge' => 'battery-half',
2019-01-20 13:37:08 -06:00
'chromatic_dispersion' => 'indent',
'cooling' => 'thermometer-full',
'count' => 'hashtag',
'current' => 'bolt fa-flip-horizontal',
2018-05-09 08:05:17 -05:00
'dbm' => 'sun-o',
2019-01-20 13:37:08 -06:00
'delay' => 'clock-o',
'eer' => 'snowflake-o',
'fanspeed' => 'refresh',
'frequency' => 'line-chart',
'humidity' => 'tint',
2018-05-09 08:05:17 -05:00
'load' => 'percent',
2019-01-20 13:37:08 -06:00
'power' => 'power-off',
'power_consumed' => 'plug',
'power_factor' => 'calculator',
'pressure' => 'thermometer-empty',
'quality_factor' => 'arrows',
2018-05-09 08:05:17 -05:00
'runtime' => 'hourglass-half',
'signal' => 'wifi',
'snr' => 'signal',
2019-01-20 13:37:08 -06:00
'state' => 'bullseye',
'temperature' => 'thermometer-three-quarters',
'voltage' => 'bolt',
2018-05-09 08:05:17 -05:00
'waterflow' => 'tint',
);
// ---- Helper Functions ----
public function classDescr()
{
$nice = collect([
'ber' => 'BER',
'dbm' => 'dBm',
'eer' => 'EER',
'snr' => 'SNR',
]);
return $nice->get($this->sensor_class, ucwords(str_replace('_', ' ', $this->sensor_class)));
}
public function icon()
{
2019-01-20 13:37:08 -06:00
return collect(self::$icons)->get($this->sensor_class, 'delicius');
}
// for the legacy menu
public static function getIconMap()
{
return self::$icons;
2018-05-09 08:05:17 -05:00
}
// ---- Define Relationships ----
public function events()
{
return $this->morphMany(Eventlog::class, 'events', 'type', 'reference');
}
2018-05-09 08:05:17 -05:00
}