© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
17 replies
einnlleinhatt_

2 Resources 1 Model

Good evening, I have a Category model and migration. My goal is to have a category and sub categor. Everything is smooth until I want a separate resources for category and sub category.

For example inside CategoryResource only have
- Image
- Name
- Status

And in inside the SubCategoryResource will have
- Image
- Name
- Category
- Ststus

Any advice how to achieve this?
Solution
In CategoryResource, You need to modify the $table by adding
->modifyQueryUsing(fn($query) => $query->whereNull('parent_id'))
->modifyQueryUsing(fn($query) => $query->whereNull('parent_id'))
. The same in SubCategoryResource with reversing the condition to only show the sub-categories.
Jump to solution
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Multiple Resources per Model
FilamentFFilament / ❓┊help
2y ago
Using 1 model in 2 Different Resource
FilamentFFilament / ❓┊help
3y ago
same model policy: multiple resources
FilamentFFilament / ❓┊help
2y ago
Using same model for multiple resources
FilamentFFilament / ❓┊help
16mo ago