vendredi 23 décembre 2016

Laravel - A show can have multiple providers

So I am trying to figure a solution to this but not sure exactly how to do this. I have a table that stores all the shows that happen. In a given show I can have multiple providers attend that show. A provider could also attend many shows as well. So how do I store this in the DB and do the eloquent relationship?

Show Schema

Schema::create('shows', function (Blueprint $table) {
  $table->increments('id');
  $table->string('name');
  $table->integer('number')->unsigned();
  $table->dateTime('airDate');
  $table->string('podcastUrl')->nullable();
  $table->timestamps();
});

Provider Schema

Schema::create('providers', function (Blueprint $table) {
  $table->increments('id');
  $table->string('name');
  $table->string('shortName')->nullable();
  $table->string('image')->nullable();
  $table->string('social')->nullable();
  $table->timestamps();
});

Would I store the provider_id in the shows schema?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire