Team.php 675 B

123456789101112131415161718192021222324252627282930313233
  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. $cal_ids = CalendarGame::where('home_team_id', '=', $this->id)->groupBy('calendar_id')->pluck('calendar_id');
  18. $calendars = Calendar::whereIn('id', $cal_ids)->get();
  19. //$calendar = Calendar::where('id', '=', @$game->calendar_id)->first();
  20. return $calendars;
  21. }
  22. public function season()
  23. {
  24. return $this->belongsTo('App\Season');
  25. }
  26. }