class Label extends Model
{
use SoftDelete;
protected $deleteTime = 'delete_time';
public function informs()
{
return $this->belongsToMany(Inform::class,'inform_label','inform_id','label_id');
}
}class InformLabel extends Pivot
{
protected $autoWriteTimestamp = true;
}//Label的model中
public static function getWithInformById($id)
{
$res = self::with(['informs'])->find($id);
return $res;
}无法查询出携带关联表对应结果的数据, 最佳答案