データベースを作成まず、それぞれのDBを作成します。 すでにpostsテーブルやtagsが存在する場合でもそれぞれに影響を与えることなく実装できるのもこのリレーションの素晴らしいところですね。 php artisan make:migration create_posts_table #すでにある場合は必要ありません。 php artisan make:migration create_tags_table #すでにある場合は必要ありません。 php artisan make:migration create_post_tag_table 各migrationファイルは以下のようにします。 # create_posts_table.php Schema::create('posts', function (Blueprint $table) { $table->increments('id
![Laravel5.2で多対多(BelongsToMany)のリレーション | Will Style Inc.|神戸にあるウェブ制作会社](https://cdn-ak-scissors.b.st-hatena.com/image/square/659951864d3c1bf28c1f2701cbadb4f4f5f551f2/height=288;version=1;width=512/https%3A%2F%2Fwillstyle.co.jp%2Fw%2Fwp-content%2Fuploads%2F2016%2F05%2Flaravel-belongsToMany-2000x1000.jpg)