我有2个模型(标签,类别),可以将其变形为视频,例如,我想知道有没有一种方法可以获取与标签相关的所有视频 像这样
$videos = Video::all();
$tags = $videos->tags($videos);
视频表架构
public function up()
{
Schema::create('videos', function (Blueprint $table) {
$table->increments('id');
$table->string('name')->index();
$table->string('link');
$table->timestamps();
});
}
标签表
public function up()
{
Schema::create('tags', function (Blueprint $table) {
$table->increments('id');
$table->string('name')->nullable();
});
}
和类别表
public function up()
{
Schema::create('categories', function (Blueprint $table) {
$table->increments('id');
$table->integer('name');
});
}
并在此处确定可观看视频的表格
public function up()
{
Schema::create('videoables', function (Blueprint $table) {
$table->increments('id');
$table->integer('video_id');
$table->integer('videoable_id');
$table->string('videoable_type');
$table->timestamps();
});