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

@@ -242,6 +242,11 @@ class Address extends Model
->with(['zone.domain']);
}
public function dynamics()
{
return $this->hasMany(Dynamic::class);
}
/**
* Echoareas this address is subscribed to
*
@@ -691,6 +696,19 @@ class Address extends Model
}
}
/**
* Files waiting to be sent to this system
*
* @return Collection
*/
public function dynamicWaiting(): Collection
{
return $this->dynamics()
->where('next_at','<=',Carbon::now())
->where('active',TRUE)
->get();
}
/**
* Echomail waiting to be sent to this system
*

32
app/Models/Dynamic.php Normal file
View File

@@ -0,0 +1,32 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Rennokki\QueryCache\Traits\QueryCacheable;
use App\Casts\CollectionOrNull;
class Dynamic extends Model
{
use SoftDeletes,QueryCacheable;
protected $casts = [
'arguments' => CollectionOrNull::class,
'next_at' => 'datetime:Y-m-d H:i:s',
'start_date' => 'datetime:Y-m-d',
'start_time' => 'datetime:H:i:s',
];
/* RELATIONS */
public function address()
{
return $this->belongsTo(Address::class);
}
/* ATTRIBUTES */
/* METHODS */
}