|null $resource * @return void */ public function __construct($name, $attribute = null, $resource = null) { parent::__construct($name, $attribute, $resource); $this->hasManyThroughRelationship = $this->attribute = $attribute ?? ResourceRelationshipGuesser::guessRelation($name); } /** * Get the relationship name. * * @return string */ public function relationshipName() { return $this->hasManyThroughRelationship; } /** * Get the relationship type. * * @return string */ public function relationshipType() { return 'hasManyThrough'; } /** * Make current field behaves as panel. * * @return \Laravel\Nova\Panel */ public function asPanel() { return Panel::make($this->name, [$this]) ->withMeta([ 'prefixComponent' => true, ])->withComponent('relationship-panel'); } /** * Prepare the field for JSON serialization. * * @return array */ public function jsonSerialize(): array { return array_merge([ 'collapsable' => $this->collapsable, 'collapsedByDefault' => $this->collapsedByDefault, 'hasManyThroughRelationship' => $this->hasManyThroughRelationship, 'relatable' => true, 'perPage' => $this->resourceClass::$perPageViaRelationship, 'resourceName' => $this->resourceName, 'singularLabel' => $this->singularLabel ?? $this->resourceClass::singularLabel(), ], parent::jsonSerialize()); } }