| 123456789101112131415161718192021222324252627282930313233 |
- <?php
- namespace App;
- use App\CalendarGame;
- use Illuminate\Database\Eloquent\Model;
- class Team extends Model
- {
- protected $fillable = [
- 'name',
- 'penality',
- 'excluded',
- 'day',
- 'type',
- 'season_id'
- ];
- function getCalendar()
- {
- $cal_ids = CalendarGame::where('home_team_id', '=', $this->id)->groupBy('calendar_id')->pluck('calendar_id');
- $calendars = Calendar::whereIn('id', $cal_ids)->get();
- //$calendar = Calendar::where('id', '=', @$game->calendar_id)->first();
- return $calendars;
- }
- public function season()
- {
- return $this->belongsTo('App\Season');
- }
- }
|