<?php
/**
Created by PhpStorm.
User: Administrator
Date: 2017/7/31
Time: 10:29
*/
namespace App\Api\V1\Models;
use Illuminate\Database\Eloquent\Model;
class Tags extends Model
{
protected $table ='tags';
public function news()
{
return $this->morphedByMany(News::class,'tags');
}
public function lessons()
{
return $this->morphedByMany(Lesson::class);
}
}
这是我的Model代码
这是报错
{"message":"SQLSTATE[42S22]: Column not found: 1054 Unknown column 'tags.tags_id' in 'field list' (SQL: select news
.*, tags
.tags_id
as pivot_tags_id
from news
inner join tags
on news
.id
= tags
.tags_id
where tags
.tags_id
= 1 and tags
.tags_type
= App\\Api\\V1\\Models\\News)","code":"42S22","status_code":500}