laravel雄辩的with()方法,$ this-> model :: find($ no)->持有人可以看到结果。但是方法总是为空
public function holder()
{
return $this->belongsTo('App\Entities\Holder', 'holder_no', 'no');
}
public function bankAccount()
{
return $this->hasMany('App\Entities\BankAccount', 'holder_no', 'no');
}
public function getBankCardDetail(array $params): array
{
$card_detail = $this->model::with('holder:no,name')
->select([
'holder_no'
])
->where([
'no'=>$params['no']
])
->first()
->toArray();
return $card_detail;
}
"data": {
"holder_no": "XXXXXXXXXX",
"holder": null
}
select `holder_no` from `bank_accounts` where (`no` = 'CGRWVF93HAOYHXZSCR4KVZ') limit 1
select `no`, `name` from `holders` where `holders`.`no` in (0)
我不知道问题出在哪里。 laravel 5.8
答案 0 :(得分:0)
no和名称应以不起作用的方式选择。