chas-academy / dragons-06-imdb-clone

1 stars 3 forks source link

Model: Genres #131

Closed axeberg closed 6 years ago

axeberg commented 6 years ago

genres:

php artisan make:migration create_genres_table --create=genres

$table->increments('id');
$table->string('genre_title')->nullable();
$table->timestamps();

genre_movie:

php artisan make:migration create_genre_movie_table --create=genre_movie

$table->increments('id');
$table->integer('genre_id')->unsigned();
$table->integer('movie_id')->unsigned();
$table->timestamps();

relationship (this goes in genre_movies table):

$table->foreign('genre_id')->references('genres')->on('id')->onDelete('cascade');
$table->foreign('movie_id')->references('movies')->on('id')->onDelete('cascade');