سؤال

I have a DataObject with multiple entries. Each entry has a variable named Sum.

I would like to add all the Sum variables together with a function on the related page.

How do I do this?

هل كانت مفيدة؟

المحلول

You can use something like:

public function getTotalSum() {
    return MyDataObject::get()->sum('Sum');
}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top