質問

In Eloquent, you can do this:

public function children() {
    return $this->hasMany('page');
}

And in Ardent, you can do this:

public static $relationsData = [
    'children' => [self::HAS_MANY, 'Page'],
];

In Eloquent, you can also do this:

public function children() {
    return $this->hasMany('page')->orderBy('sort_order', 'desc');
}

Is there any way to do that, or get the same effect as that in Ardent?

I really like the short Ardent notation, but don't want to have to call $page->children->ordered() with a scope just to order them, as they'll need to be ordered every single time it's called anyway.

役に立ちましたか?

解決

As it turns out, it's just not possible. You need the full definition if you want to do anything more than the basic relation functionality.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top