Implemented Dynamic Items for data to be sent to polled systems based on data in db, like stats/nodelists

This commit is contained in:
2023-12-03 18:18:05 +11:00
parent 8f3d77b04d
commit 1890b66dc7
10 changed files with 366 additions and 4 deletions

View File

@@ -1,12 +1,13 @@
<?php
/**
* Calculate CCITT-CRC16 checksum
*/
use Carbon\Carbon;
use Illuminate\Support\Collection;
use App\Models\{Setup,Zone};
/**
* Calculate CCITT-CRC16 checksum
*/
if (! function_exists('crc16')) {
function crc16($data): int
{
@@ -80,6 +81,22 @@ if (! function_exists('hexstr')) {
}
}
/**
* Return our addresses.
* If zone provided, limit the list to those within the zone
*
* @param Zone|NULL $zo
* @return Collection
*/
function our_address(Zone $zo=NULL): Collection
{
$our = Setup::findOrFail(config('app.id'))->system->addresses;
return $zo
? $our->filter(function($item) use ($zo) { return $item->zone_id === $zo->id; })
: $our;
}
if (! function_exists('timew')) {
/**
* Convert a time into an 32 bit value. This is primarily used to create 8 character hex filenames that