You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
519 B

  1. <?php
  2. namespace App;
  3. use Illuminate\Database\Eloquent\Model;
  4. class Team extends Model
  5. {
  6. protected $fillable = [
  7. 'name', 'color'
  8. ];
  9. public function players() {
  10. return $this->hasMany('App\Player');
  11. }
  12. public function tweets() {
  13. return $this->hasMany('App\Tweet');
  14. }
  15. public function total_score() {
  16. $score = 0;
  17. $missions = Mission::get();
  18. foreach($missions as $mission) {
  19. $score += $mission->score($this);
  20. }
  21. return $score;
  22. }
  23. }