| Total Complexity | 6 |
| Total Lines | 30 |
| Duplicated Lines | 0 % |
| Coverage | 71.43% |
| Changes | 0 | ||
| 1 | <?php |
||
| 7 | trait Publishable |
||
| 8 | { |
||
| 9 | 89 | public function isPublished(): bool |
|
| 10 | { |
||
| 11 | 89 | return $this->state() === PageState::PUBLISHED; |
|
|
|
|||
| 12 | } |
||
| 13 | |||
| 14 | 85 | public function isDraft(): bool |
|
| 15 | { |
||
| 16 | 85 | return $this->state() === PageState::DRAFT; |
|
| 17 | } |
||
| 18 | |||
| 19 | 5 | public function scopePublished($query) |
|
| 20 | { |
||
| 21 | // Here we widen up the results in case of preview mode and ignore the published scope |
||
| 22 | 5 | if (PreviewMode::fromRequest()->check()) { |
|
| 23 | return; |
||
| 24 | } |
||
| 25 | |||
| 26 | 5 | $query->where('current_state', PageState::PUBLISHED); |
|
| 27 | 5 | } |
|
| 28 | |||
| 29 | public function scopeDrafted($query) |
||
| 32 | } |
||
| 33 | |||
| 34 | 3 | public static function getAllPublished() |
|
| 37 | } |
||
| 38 | } |
||
| 39 |