$resourceRelated * @param string $relation * @param bool|null $shouldUseName * @param int|null $limit * @return static */ public function urlToRelated(string $resourceRelated, string $relation, ?bool $shouldUseName = false, ?int $limit = null): static { return $this ->weight(FontWeight::SemiBold) ->html() ->hiddenOn(BaseRelationManager::class) ->url(function (BaseModel $record) use ($resourceRelated, $relation, $shouldUseName, $limit) { foreach (explode('.', $relation) as $element) { $record = Arr::get($record, $element); if ($record === null) return null; } $this->formatStateUsing(function ($state) use ($shouldUseName, $record, $limit) { $name = $shouldUseName ? $record->getName() : $state; $nameLimited = Str::limit($name, $limit ?? 100); return "
{$nameLimited}
"; }); return (new $resourceRelated)::getUrl('edit', ['record' => $record]); }); } /** * Make the column copyable. * * @param bool $condition * @return static */ public function copyableWithMessage(bool $condition = true): static { return $this ->copyable($condition) ->copyMessage(__('filament.actions.base.copied')); } }