init
This commit is contained in:
19
app/Models/Concerns/HasPublicationScope.php
Normal file
19
app/Models/Concerns/HasPublicationScope.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?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());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user