20 lines
415 B
PHP
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());
|
||
|
|
}
|
||
|
|
}
|