diff --git a/app/PostsTag.php b/app/PostsTag.php new file mode 100644 index 0000000..7fb54c9 --- /dev/null +++ b/app/PostsTag.php @@ -0,0 +1,12 @@ +bigIncrements('id'); + $table->timestamps(); + $table->string('name')->unique(); + }); + + Schema::create('posts_tags', function (Blueprint $table) { + $table->bigIncrements('id'); + $table->timestamps(); + $table->bigInteger('post_id'); + $table->bigInteger('tag_id'); + $table->foreign('post_id')->references('id')->on('posts'); + $table->foreign('tag_id')->references('id')->on('tags'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('tags'); + Schema::dropIfExists('posts_tags'); + } +} diff --git a/database/seeds/DatabaseSeeder.php b/database/seeds/DatabaseSeeder.php index 91cb6d1..23fe5d1 100755 --- a/database/seeds/DatabaseSeeder.php +++ b/database/seeds/DatabaseSeeder.php @@ -11,6 +11,8 @@ class DatabaseSeeder extends Seeder */ public function run() { - // $this->call(UsersTableSeeder::class); + $this->call([ + TagsTableSeeder::class + ]); } } diff --git a/database/seeds/TagsTableSeeder.php b/database/seeds/TagsTableSeeder.php new file mode 100644 index 0000000..05fa9a8 --- /dev/null +++ b/database/seeds/TagsTableSeeder.php @@ -0,0 +1,29 @@ +insert(['name' => 'Voyages', 'created_at' => \Carbon\Carbon::now()]); + DB::table('tags')->insert(['name' => 'Étapes', 'created_at' => \Carbon\Carbon::now()]); + DB::table('tags')->insert(['name' => 'Santé', 'created_at' => \Carbon\Carbon::now()]); + DB::table('tags')->insert(['name' => 'Humeur', 'created_at' => \Carbon\Carbon::now()]); + DB::table('tags')->insert(['name' => 'Idée', 'created_at' => \Carbon\Carbon::now()]); + DB::table('tags')->insert(['name' => 'Connaissance', 'created_at' => \Carbon\Carbon::now()]); + DB::table('tags')->insert(['name' => 'Habitudes', 'created_at' => \Carbon\Carbon::now()]); + DB::table('tags')->insert(['name' => 'Nourriture', 'created_at' => \Carbon\Carbon::now()]); + DB::table('tags')->insert(['name' => 'Gratitude', 'created_at' => \Carbon\Carbon::now()]); + DB::table('tags')->insert(['name' => 'Fitness', 'created_at' => \Carbon\Carbon::now()]); + DB::table('tags')->insert(['name' => 'Rêves', 'created_at' => \Carbon\Carbon::now()]); + DB::table('tags')->insert(['name' => 'Travail', 'created_at' => \Carbon\Carbon::now()]); + } +}