我正在尝试编码一个连接,但是找不到列-我知道它确实存在。此加入有抱怨的具体原因吗?这是我写的第一个加入,可能错过了什么?
$applicationsWithNoFinalOutcome = $career->select('v2_careers.id', 'v2_careers.name', 'v2_applications.id', 'v2_applications.name')
->join('v2_application_outcomes', 'v2_application_outcomes.application_uuid', '=', 'v2_applications.uuid')
->join('v2_applications', 'v2_applications.uuid', '=', 'v2_application_outcomes.applicant_uuid')
->where('v2_application_outcomes.is_final_success_outcome', 0)
->where('v2_application_outcomes.is_final_reject_outcome', 0);
SQL:
SELECT `v2_careers`.`id`,
`v2_careers`.`name` ,
`v2_applications`.`id, v2_applications`.`name`
FROM `v2_careers`
INNER JOIN `v2_application_outcomes` ON `v2_application_outcomes`.`application_uuid` = `v2_applications`.`uuid`
INNER JOIN `v2_applications` ON `v2_applications`.`uuid` = `v2_application_outcomes`.`applicant_uuid`
WHERE `v2_application_outcomes`.`is_final_success_outcome` = ?
AND `v2_application_outcomes`.`is_final_success_outcome` = ?
AND `v2_careers`.`deleted_at` IS NULL
v2_应用程序迁移
Schema::create('v2_applications', function (Blueprint $table) {
$table->increments('id');
$table->char('uuid', 30)->unique()->index();
$table->char('career_uuid', 30)->index();
$table->integer('applicant_id')->unsigned()->index();
$table->text('cover_letter')->nullable();
$table->dateTime('viewed_at')->nullable();
$table->integer('thread_id')->unsigned()->nullable()->index();
$table->timestamps();
$table->softDeletes();
// Foreign keys
$table->foreign('career_uuid')->references('uuid')->on('v2_careers');
$table->foreign('applicant_id')->references('id')->on('users');
$table->foreign('thread_id')->references('id')->on('threads');
});