我有三张 table :1 . 问题库2.问题类型3.问题

我需要检索json响应:

[{"questiontitle":"OSCE","questionbank":"osce bank","questiontype":"osce type"}]

我的模特是:

  • questionbank

class Questionbank扩展Model {

protected $fillable = [];

protected $table = "QuestionBank";

protected $dates = [];
protected $primaryKey = "QuestionBankID";

protected $visible = ["QuestionBank"];

public static $rules = [
    // Validation rules
];

}

  • 问题类型

class questiontype extends Model {

protected $fillable = [];

protected $dates = [];

protected $table = "QuestionType";

protected $primarykey = "QuestionTypeID";

protected $visible = ["QuestionType"];

public static $rules = [
    // Validation rules
];

// Relationships

}

  • 问题

class Questions扩展Model {

protected $fillable = ["QuestionTitle"];

protected $dates = [];

protected $primaryKey = "QuestionID";
protected $foreignKey = "QuestionBankID";

public static $rules = [
    // Validation rules
];
protected $visible = ["QuestionTitle","QuestionBank","QuestionType"];
// Relationships

公共函数QuestionBank(){return $ this-> hasManyThrough('App \ QuestionBank','App \ questiontype','QuestionBankID','QuestionTypeID','QuestionBankID','QuestionTypeID'); }}

我收到了错误:

Column not found: 1054 Unknown column 'QuestionType.QuestionBankID' in 'field list' (SQL: select `QuestionBank`.*, `QuestionType`.`QuestionBankID` from `QuestionBank` inner join `QuestionType` on `QuestionType`.`QuestionTypeID` = `QuestionBank`.`QuestionTypeID` where `QuestionType`.`QuestionBankID`