think\model\Relation::hasMany PHP Метод

hasMany() публичный Метод

HAS MANY 关联定义
public hasMany ( string $model, string $foreignKey, string $localKey, array $alias )
$model string 模型名
$foreignKey string 关联外键
$localKey string 关联主键
$alias array 别名定义
    public function hasMany($model, $foreignKey, $localKey, $alias)
    {
        // 记录当前关联信息
        $this->type = self::HAS_MANY;
        $this->model = $model;
        $this->foreignKey = $foreignKey;
        $this->localKey = $localKey;
        $this->alias = $alias;
        $this->query = (new $model())->db();
        // 返回关联的模型对象
        return $this;
    }