diff --git a/app/Hashtag.php b/app/Hashtag.php new file mode 100644 index 000000000..497bc94ee --- /dev/null +++ b/app/Hashtag.php @@ -0,0 +1,28 @@ +hasManyThrough( + Status::class, + StatusHashtag::class, + 'hashtag_id', + 'id', + 'id', + 'status_id' + ); + } + + public function url() + { + return config('routes.hashtag.base') . $this->slug; + } + +} diff --git a/database/migrations/2018_05_06_214815_create_hashtags_table.php b/database/migrations/2018_05_06_214815_create_hashtags_table.php new file mode 100644 index 000000000..d8a3497c9 --- /dev/null +++ b/database/migrations/2018_05_06_214815_create_hashtags_table.php @@ -0,0 +1,35 @@ +bigIncrements('id'); + $table->string('name')->unique()->index(); + $table->string('slug')->unique()->index(); + $table->boolean('is_nsfw')->default(false); + $table->boolean('is_banned')->default(false); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('hashtags'); + } +} diff --git a/database/migrations/2018_05_06_215006_create_status_hashtags_table.php b/database/migrations/2018_05_06_215006_create_status_hashtags_table.php new file mode 100644 index 000000000..a4311d063 --- /dev/null +++ b/database/migrations/2018_05_06_215006_create_status_hashtags_table.php @@ -0,0 +1,34 @@ +bigIncrements('id'); + $table->bigInteger('status_id')->unsigned()->index(); + $table->bigInteger('hashtag_id')->unsigned()->index(); + $table->unique(['status_id', 'hashtag_id']); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('status_hashtags'); + } +}