first commit
This commit is contained in:
33
src/Models/Site.php
Normal file
33
src/Models/Site.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Core\Model;
|
||||
|
||||
class Site extends Model
|
||||
{
|
||||
protected static string $table = 'sites';
|
||||
|
||||
public static function findActive(): array
|
||||
{
|
||||
return self::where('is_active = 1', [], 'last_published_at ASC');
|
||||
}
|
||||
|
||||
public static function findDueForPublishing(): array
|
||||
{
|
||||
$sql = "SELECT * FROM sites
|
||||
WHERE is_active = 1
|
||||
AND (
|
||||
last_published_at IS NULL
|
||||
OR DATE_ADD(last_published_at, INTERVAL publish_interval_days DAY) <= NOW()
|
||||
)
|
||||
ORDER BY last_published_at ASC";
|
||||
$stmt = self::db()->query($sql);
|
||||
return $stmt->fetchAll();
|
||||
}
|
||||
|
||||
public static function updateLastPublished(int $id): void
|
||||
{
|
||||
self::update($id, ['last_published_at' => date('Y-m-d H:i:s')]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user