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.

33 lines
597 B

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