NotificationFilter.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace App\ModelFilters;
  3. use EloquentFilter\ModelFilter;
  4. class NotificationFilter extends ModelFilter
  5. {
  6. /**
  7. * Related Models that have ModelFilters as well as the method on the ModelFilter
  8. * As [relationMethod => [input_key1, input_key2]].
  9. *
  10. * @var array
  11. */
  12. public $relations = [];
  13. public function startReadAt($date)
  14. {
  15. return $this->where("notification_records.read_at", ">=", $date);
  16. }
  17. public function endReadAt($date)
  18. {
  19. return $this->where("notification_records.read_at", "<", $date);
  20. }
  21. public function startNotificationAt($date)
  22. {
  23. return $this->where("notifications.created_at", ">=", $date);
  24. }
  25. public function endNotificationAt($date)
  26. {
  27. return $this->where("notifications.created_at", "<", $date);
  28. }
  29. public function readStatus($status)
  30. {
  31. return !$status
  32. ? $this->whereNull("notification_records.read_at")
  33. : $this->whereNotNull("notification_records.read_at");
  34. }
  35. }