The required surface
public function getFromUser(): ?User { return $this->actor; // may be null for system notifications } public function getSubject() { return $this->thing; } public function getAttributes() { return ['thingId' => $this->thing->id]; } public static function getType() { return 'myThing'; } public static function getSubjectModel() { return Thing::class; } Returning null is fine and is the right answer for a notification not attributable to a person. Omitting the method entirely is not.
Related: Flarum 2: frontend model relations must use the hasOne/hasMany call pattern, Flarum 2: json-api-server returns 403 for declared but unwritable fields
- 0 comments
- 29 views