I have a season, and each clan has to have a valid season entry. The stage I'm currently stuck on is how can I have a relationship for clans in my Season class?
This would help me understand which clans a season currently holds, but without a complicated query, it seems impossible with relationships. Is there a 'good practice' way of doing this?
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Season extends Model
{
public function matches() {
return $this->hasMany('App\ClanMatch', 'season_id');
}
public function tournaments() {
return $this->hasMany('App\Tournament', 'season_id');
}
}
class SeasonEntry extends Model
{
public function season() {
return $this->belongsTo('App\Season', 'season_id');
}
public function clan() {
return $this->belongsTo('App\Clan', 'clan_id');
}
}