lundi 8 février 2021

Laravel, need a suggestion on how to make team playing in few leagues

i have leagues and teams tables.

releationship between these tables:

League model:

public function teams()
    {
        return $this->hasMany('App\Team');
    }

Team Model:

public function league() {
        return $this->belongsTo('App\League');
    }

maybe you have tips on how I can make a team belong to more than one league?

Also here is both tables schemas:

Schema::create('leagues', function (Blueprint $table) {
            $table->id();
            $table->string('name');
            $table->uuid('season_id')->nullable();
            $table->timestamps();
        });

 Schema::create('teams', function (Blueprint $table) {
            $table->id();
            $table->integer('league_id')->nullable();
            $table->string('name');
            $table->string('city');
            $table->string('team_logo')->nullable();
            $table->string('stadium')->nullable();
            $table->timestamps();
        });


from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3aOTGWs
via IFTTT

Aucun commentaire:

Enregistrer un commentaire