| @@ 126-135 (lines=10) @@ | ||
| 123 | return is_null($this->from_id); |
|
| 124 | } |
|
| 125 | ||
| 126 | public function scopeByCategory(Builder $query, $category) |
|
| 127 | { |
|
| 128 | $categoryId = $category; |
|
| 129 | if ($category instanceof NotificationCategory) { |
|
| 130 | $categoryId = $category->getKey(); |
|
| 131 | } elseif (!is_numeric($category)) { |
|
| 132 | $categoryId = NotificationCategory::byName($category)->firstOrFail()->getKey(); |
|
| 133 | } |
|
| 134 | ||
| 135 | return $query->where('category_id', $categoryId); |
|
| 136 | } |
|
| 137 | ||
| 138 | public function scopeByRead(Builder $query, $read = 1) |
|
| @@ 27-39 (lines=13) @@ | ||
| 24 | $this->typeChecker = new TypeChecker(); |
|
| 25 | } |
|
| 26 | ||
| 27 | public function category($category) |
|
| 28 | { |
|
| 29 | $categoryId = $category; |
|
| 30 | if ($category instanceof NotificationCategory) { |
|
| 31 | $categoryId = $category->getKey(); |
|
| 32 | } elseif (!is_numeric($category)) { |
|
| 33 | $categoryId = NotificationCategory::byName($category)->firstOrFail()->getKey(); |
|
| 34 | } |
|
| 35 | ||
| 36 | $this->setNotificationData('category_id', $categoryId); |
|
| 37 | ||
| 38 | return $this; |
|
| 39 | } |
|
| 40 | ||
| 41 | public function from() |
|
| 42 | { |
|