Files
ai-web/app/Models/Concerns/HasPublicationScope.php
jiangdong.cheng aa16c9f8c2
Some checks failed
Tests / PHP 8.2 (push) Has been cancelled
Tests / PHP 8.3 (push) Has been cancelled
Tests / PHP 8.4 (push) Has been cancelled
init
2026-02-11 17:28:36 +08:00

20 lines
415 B
PHP

<?php
declare(strict_types=1);
namespace App\Models\Concerns;
use App\Enums\EntityStatus;
use Illuminate\Database\Eloquent\Builder;
trait HasPublicationScope
{
public function scopePublished(Builder $query): Builder
{
return $query
->where('status', EntityStatus::Published->value)
->whereNotNull('published_at')
->where('published_at', '<=', now());
}
}