Metadata - Tags の多対多リレーション追加
This commit is contained in:
parent
91c786199a
commit
1322e89b86
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateMetadataTagTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('metadata_tag', function (Blueprint $table) {
|
||||
$table->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');
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user