Total Complexity | 2 |
Total Lines | 38 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
8 | trait PublishedTrait |
||
9 | { |
||
10 | protected string $publishedField = 'published_at'; |
||
11 | |||
12 | /** |
||
13 | * Apply conditions to retrieve published posts. |
||
14 | * |
||
15 | * Conditions: |
||
16 | * - Includes posts where `published_at` is `NULL` (considered as already published). |
||
17 | * - Includes posts where `published_at` is in the past or equal to the current time. |
||
18 | * |
||
19 | * @param Builder $query The query builder instance. |
||
20 | * @return Builder The modified query with applied conditions. |
||
21 | */ |
||
22 | public function applyPublisedConditions(Builder $query): Builder |
||
28 | }); |
||
29 | } |
||
30 | |||
31 | /** |
||
32 | * Apply conditions to retrieve scheduled (future) posts. |
||
33 | * |
||
34 | * Conditions: |
||
35 | * - Excludes posts where `published_at` is `NULL` (not scheduled). |
||
36 | * - Includes posts where `published_at` is in the future. |
||
37 | * |
||
38 | * @param Builder $query The query builder instance. |
||
39 | * @return Builder The modified query with applied conditions. |
||
40 | */ |
||
41 | public function applyNotPublisedConditions(Builder $query): Builder |
||
48 |