v0.9.0: no-MAC device tracking, IP-change dashboard, extended search
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class NetworkIpNote extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'segment_id',
|
||||
'ip_address',
|
||||
'note',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
];
|
||||
|
||||
public function segment(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(NetworkSegment::class);
|
||||
}
|
||||
}
|
||||
@@ -10,14 +10,44 @@ use Illuminate\Database\Eloquent\Relations\HasManyThrough;
|
||||
class NetworkSegment extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'name', 'subnet', 'vlan_id', 'active', 'description', 'created_by',
|
||||
'name', 'subnet', 'vlan_id', 'active', 'description',
|
||||
'scan_interval_minutes', 'last_scanned_at', 'nmap_options', 'created_by',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'active' => 'boolean',
|
||||
'vlan_id' => 'integer',
|
||||
'active' => 'boolean',
|
||||
'vlan_id' => 'integer',
|
||||
'scan_interval_minutes' => 'integer',
|
||||
'last_scanned_at' => 'datetime',
|
||||
];
|
||||
|
||||
/** Ist ein automatischer Scan fällig? */
|
||||
public function isScanDue(): bool
|
||||
{
|
||||
if (!$this->active || !$this->scan_interval_minutes) {
|
||||
return false;
|
||||
}
|
||||
if (!$this->last_scanned_at) {
|
||||
return true;
|
||||
}
|
||||
return $this->last_scanned_at->addMinutes($this->scan_interval_minutes)->isPast();
|
||||
}
|
||||
|
||||
/** Lesbare Intervall-Beschreibung */
|
||||
public function getScanIntervalLabelAttribute(): string
|
||||
{
|
||||
return match($this->scan_interval_minutes) {
|
||||
5 => 'alle 5 Minuten',
|
||||
15 => 'alle 15 Minuten',
|
||||
30 => 'alle 30 Minuten',
|
||||
60 => 'stündlich',
|
||||
360 => 'alle 6 Stunden',
|
||||
720 => 'alle 12 Stunden',
|
||||
1440 => 'täglich',
|
||||
default => 'manuell',
|
||||
};
|
||||
}
|
||||
|
||||
public function createdBy(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'created_by');
|
||||
|
||||
Reference in New Issue
Block a user