TaskFilter.php 603 B

123456789101112131415161718192021222324252627
  1. <?php
  2. namespace App\ModelFilters;
  3. use EloquentFilter\ModelFilter;
  4. use Illuminate\Support\Facades\Auth;
  5. class TaskFilter extends ModelFilter
  6. {
  7. /**
  8. * Related Models that have ModelFilters as well as the method on the ModelFilter
  9. * As [relationMethod => [input_key1, input_key2]].
  10. *
  11. * @var array
  12. */
  13. public $relations = [];
  14. public function status(string $status): TaskFilter
  15. {
  16. return $this->where("status", $status);
  17. }
  18. public function my(string $my): TaskFilter
  19. {
  20. return $my == "yes" ? $this->where("assign", Auth::id()) : $this;
  21. }
  22. }