© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
1 reply
bernhard

Route model Binding

I have different models, where I have a
published_at
published_at
date as a field and I have different routes, where I use these models with route bindings.

On the front end, I only want to show "published" models (aka
published_at > now()
published_at > now()
). This is easily done by adding the following to the models:

public function resolveRouteBindingQuery($query, $value, $field = null)
{
    return parent::resolveRouteBindingQuery($query, $value, $field)->where("published_at", ">", now());
}
public function resolveRouteBindingQuery($query, $value, $field = null)
{
    return parent::resolveRouteBindingQuery($query, $value, $field)->where("published_at", ">", now());
}


The problem is, that this logic obviously also kicks in in admin panel, so I get a 404 on "unpublished" resources.

Any elegent solutions for this? For example, can I exclude somehow the admin from my
resolveRouteBindingQuery
resolveRouteBindingQuery
logic?
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Route model binding
FilamentFFilament / ❓┊help
3y ago
Model Binding/Extending
FilamentFFilament / ❓┊help
3y ago
Does Filament change Laravel's default Route Model Binding?
FilamentFFilament / ❓┊help
3y ago
Custom Page Polymorphic Model Binding
FilamentFFilament / ❓┊help
2y ago