diff --git a/app/Metadata.php b/app/Metadata.php index dc44009..d516b0b 100644 --- a/app/Metadata.php +++ b/app/Metadata.php @@ -14,4 +14,9 @@ class Metadata extends Model protected $visible = ['url', 'title', 'description', 'image', 'expires_at']; protected $dates = ['created_at', 'updated_at', 'expires_at']; + + public function tags() + { + return $this->belongsToMany(Tag::class)->withTimestamps(); + } } diff --git a/database/migrations/2019_04_29_111019_create_metadata_tag_table.php b/database/migrations/2019_04_29_111019_create_metadata_tag_table.php new file mode 100644 index 0000000..fdef664 --- /dev/null +++ b/database/migrations/2019_04_29_111019_create_metadata_tag_table.php @@ -0,0 +1,33 @@ +increments('id'); + $table->text('metadata_url')->index(); + $table->integer('tag_id')->index(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('metadata_tag'); + } +}