public static function with($model)
    {
        $data = static::model()->findAll();

        $idKey = null;
        $whereIn = [];
        foreach ($data as $key => $value) {
            $idKey = $value->primaryKey;
            $whereIn[] = $value->{$value->primaryKey};
        }

        $associatedModel = new $model();
        $associatedData = $associatedModel
            ->where(static::getForeignKey(static::model()->tableName), 'IN', implode(',', $whereIn))
            ->findAll();

        $data = static::buildRelations($data, $associatedModel, $associatedData);

        return $data;
    }