Implemented Dynamic Items for data to be sent to polled systems based on data in db, like stats/nodelists
This commit is contained in:
@@ -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
32
app/Models/Dynamic.php
Normal 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 */
|
||||
}
|
Reference in New Issue
Block a user