| @@ 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 | { |
|
| @@ 120-129 (lines=10) @@ | ||
| 117 | return $this->save(); |
|
| 118 | } |
|
| 119 | ||
| 120 | public function scopeByCategory(Builder $query, $category) |
|
| 121 | { |
|
| 122 | $categoryId = $category; |
|
| 123 | if($category instanceof NotificationCategory) { |
|
| 124 | $categoryId = $category->getKey(); |
|
| 125 | } elseif (! is_numeric($category)) { |
|
| 126 | $categoryId = NotificationCategory::byName($category)->firstOrFail()->getKey(); |
|
| 127 | } |
|
| 128 | return $query->where('category_id', $categoryId); |
|
| 129 | } |
|
| 130 | ||
| 131 | public function scopeByRead(Builder $query, $read = 1) |
|
| 132 | { |
|