【发布时间】:2019-03-22 02:14:29
【问题描述】:
表项目:
project_id (int)
requestor_id (uuid)
表请求者:
requestor_id (uuid)
模型项目:
public function requestor() {
return $this->hasOne('App\Models\Requestor', 'requestor_id', 'requestor_id');
}
模型请求者有一种方法:
// this method return object users info from ldap
public function getLdapAttribute() {
$ldapWrapper = new LdapWrapper();
return $ldapWrapper->checkIfUuidExists($this->requestor_id, true);
}
选择所有具有请求者关系的项目:
$query = (new Project)->newQuery()->with(['requestor'])->get();
问题是: 如何选择所有具有请求者关系的项目以及在每个请求者对象调用方法 getLdapAttribute 并将所有项目作为一个对象返回?
非常感谢:)
【问题讨论】:
-
您的任何代码与 sql 有什么关系??
标签: sql laravel ldap relationship