12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- <?php
- namespace App\ModelFilters;
- use EloquentFilter\ModelFilter;
- class NotificationFilter extends ModelFilter
- {
- /**
- * Related Models that have ModelFilters as well as the method on the ModelFilter
- * As [relationMethod => [input_key1, input_key2]].
- *
- * @var array
- */
- public $relations = [];
- public function startReadAt($date)
- {
- return $this->where("notification_records.read_at", ">=", $date);
- }
- public function endReadAt($date)
- {
- return $this->where("notification_records.read_at", "<", $date);
- }
- public function startNotificationAt($date)
- {
- return $this->where("notifications.created_at", ">=", $date);
- }
- public function endNotificationAt($date)
- {
- return $this->where("notifications.created_at", "<", $date);
- }
- public function readStatus($status)
- {
- return !$status
- ? $this->whereNull("notification_records.read_at")
- : $this->whereNotNull("notification_records.read_at");
- }
- }
|