Child类中不存在PHP错误方法,method_exists($ child,$ method)传递

working with Laravel 5.1 here. I have created two classes, one extending the other:

abstract class ActivityTimeline extends Model

Which has:

$this->fields = [
   'owner_id',
   'contact_name',
   'mailing_label',
   'source_id',
   'source_raw',
   'initial_referer_raw',
   'primary_person',
   'connections',
];
foreach ($this->fields as $field) {
    if (method_exists($this, $field)) {
        dd('the method exists', $this, $field);
        $timelineActivity[$field] = $this->{$field}();
    }
}

And

class ContactActivity extends ActivityTimeline {

Which has:

public function primary_person()
{
    return $this->getPrimaryPerson($this->record);
}

The "dd('the method exists', $this, $field);" returns the following:

"the method exists"

ContactActivity {#963 ▶}

"primary_person"

However when this if statement passes, and I attempt to call the method that I just checked the existence of, I get:

BadMethodCallException in Builder.php line 2123: Call to undefined method Illuminate\Database\Query\Builder::primary_person()

So it seems that I'm not working with a ContactActivity object here, even though the dd shows that I am. Anyone know what I'm doing wrong here to get the wrong object?

I think it's because you call a child method from the parent class. Try to add

abstract function primary_person();

On ActivityTimeline class