laravel 5 - PHP error method doesn't exist in the Child class, method_exists($child, $method) passes -
working laravel 5.1 here. have created 2 classes, 1 extending 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 $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 following:
"the method exists"
contactactivity {#963 ▶}
"primary_person"
however when if statement passes, , attempt call method checked existence of, get:
badmethodcallexception in builder.php line 2123: call undefined method illuminate\database\query\builder::primary_person()
so seems i'm not working contactactivity object here, though dd shows am. know i'm doing wrong here wrong object?
i think it's because call child method parent class. try add
abstract function primary_person();
on activitytimeline class
Comments
Post a Comment