novius/laravel-linkable
Manage “linkable” Eloquent models in Laravel: define per-model link configuration (URL callback or route), labels/groups/search, and query customization. Includes a Linkable Nova field plus publishable config and language files.
Strengths:
Linkable trait enables composition over inheritance, allowing selective adoption across models (e.g., only Post, Product, or User models) without forcing a monolithic architecture.optionsQuery, resolveQuery), enabling optimization for specific use cases (e.g., filtering by published status or locale).getUrlCallback and routeName/routeParameterName options accommodate both dynamic and static routing needs.previewUrl() and previewTokenField handle preview modes (e.g., for draft content), which is critical for CMS-like applications.Gaps:
Post → Post), it lacks built-in support for multi-hop queries (e.g., "find all posts linked from a user’s posts"). This may require custom query scopes or a separate graph library for complex traversals.optionSearch) should be tested.setRouteCallback, setHasRouteCallback) for customizing URL generation, which is useful for teams using localization packages (e.g., Spatie’s Laravel Translatable or Laravel Localization).vendor:publish commands allow teams to customize behavior (e.g., autoload_models_in, linkable_routes) without modifying the package’s core code.composer run test to validate edge cases.laravel-nova) adds credibility.Linkable fields in Nova/Filament could impact admin panel performance. Teams should benchmark with large datasets (e.g., 10K+ linked models).optionSearch feature impact database performance for models with many linked records?Laravel Ecosystem:
Linkable Nova field and Filament component are optional but valuable for teams using these admin tools. They reduce the need for custom field development.getUrlCallback and locale support integrate well with localization libraries (e.g., Spatie’s Laravel Translatable, Laravel Localization). Teams using these will appreciate the built-in locale handling.url() and previewUrl() methods simplify API responses by providing standardized link generation.Non-Laravel Components:
Assessment Phase:
Linkable (e.g., Post, Product, User).getUrlCallback.Pilot Phase:
Post) to test the trait, Nova/Filament field, and URL generation.linkedTo(), linkedFrom()) to validate traversal capabilities.Integration Phase:
use Novius\LaravelLinkable\Traits\Linkable;
class Post extends Model {
use Linkable;
// ...
}
linkableConfig()
Define routeName, optionLabel, optionGroup, and any custom queries (e.g., optionsQuery to filter by published).post_route) are defined to support the routeName/routeParameterName configuration.Linkable::make() or Filament’s Linkable component.$model->url() or $model->previewUrl() where applicable.Validation Phase:
Post::linkedTo($category) returns the correct results).How can I help you explore Laravel packages today?