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