Team.php 569 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. namespace App;
  3. use App\CalendarGame;
  4. use Illuminate\Database\Eloquent\Model;
  5. class Team extends Model
  6. {
  7. protected $fillable = [
  8. 'name',
  9. 'penality',
  10. 'excluded',
  11. 'day',
  12. 'type',
  13. 'season_id'
  14. ];
  15. function getCalendar()
  16. {
  17. $game = CalendarGame::where('home_team_id', '=', $this->id)->first();
  18. $calendar = Calendar::where('id', '=', @$game->calendar_id)->first();
  19. return $calendar;
  20. }
  21. public function season()
  22. {
  23. return $this->belongsTo('App\Season');
  24. }
  25. }