使用方法
$this->hasOne(class, 'local_key', 'foreign_key');
$this->hasOne(table, table_id, id);
$this->hasMany(class, 'local_key', 'foreign_key');
$this->hasMany(table, id, table_id);
流程
with('w')
with(['w' => function($query) { $query->select('a') }])
with('w:a')
eagerLoad['w'] = function(){}
eagerLoad['w'] = function($query) { $query->select('a') }
eagerLoad['w'] = function($query) { $query->select('a') }
get()
$model->w()
$this->hasOne(table, table_id, id)
$this->hasOne(table, table_id, id)->select('');
Relation{table, local_key, foreign_key} : Query
eagerLoad['w'](Relation)
Relation(id[])->getResult()
w => array
转载请保留原文链接: https://zodream.cn/blog/id/38.html