public function scopeGetCompanyInfoWithBank($query, $comCode)
{
$query->select(
DB::raw("CONCAT(rtrim(COM_NAME), '') AS COM_NAME"),
DB::raw("CONCAT(rtrim(COM_ADD1), '') AS COM_ADD1"),
DB::raw("CONCAT(rtrim(COM_ADD2), '') AS COM_ADD2"),
DB::raw("CONCAT(rtrim(COM_ADD3), '') AS COM_ADD3"),
DB::raw("CONCAT(rtrim(COM_ADD4), '') AS COM_ADD4"),
DB::raw("CONCAT(rtrim(COM_BNKCODE), '') AS COM_BNKCODE"),
DB::raw("CONCAT(rtrim(BANK_NAME), '') AS BANK_NAME") // NOT WORKING.
)
->join("bank", function ($join) {
$join->on('bank.BANK_CODE', "=", 'COM_BNKCODE');
})
->where('COM_CODE', '=', $comCode)
->get();
}
问题:
无法从上述查询中获取“ BANK_NAME”。
答案 0 :(得分:-1)
希望这会对您有所帮助
公共函数scopeGetCompanyInfoWithBank($ query,$ comCode) { $ this-> data ['query'] = company :: join('bank','BANK_CODE','=','company.COM_BNKCODE') ->选择(“ company.COM_NAME”,“ company.COM_ADD1”, 'company.COM_ADD2','company.COM_ADD3', 'company.COM_ADD4','company.COM_BNKCODE') ->哪里('company.COM_CODE','=',$ comCode) ->获取(); }