Task.php 619 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. namespace App;
  3. use Illuminate\Database\Eloquent\Model;
  4. class Task extends Model
  5. {
  6. /**
  7. * Returns a collection, so cannot be chained.
  8. *
  9. * @return \Illuminate\Database\Eloquent\Collection|static[]
  10. */
  11. public static function incomplete_v0()
  12. {
  13. return static::where('completed', 0)->get();
  14. }
  15. /**
  16. * Will answer to Task::incomplete() too but know it is a query scope.
  17. *
  18. * @param $query
  19. * The existing query.
  20. *
  21. * @return mixed
  22. */
  23. public function scopeIncomplete($query)
  24. {
  25. return $query->where('completed', 0);
  26. }
  27. }