ListCategoryPage stuck on Product model instead of Category
I’m hitting a snag: in my ProductResource the default pages (ListProduct, EditProduct, CreateProduct) work fine. I added a new ListCategoryPage to show ProductCategory under the same resource, but it still uses the Product model and lists products instead of categories. I’ve tried tweaking getModel(), mount(), even registered the page in the Resource correctly, but nothing makes it use ProductCategory. Anyone run into this or know if you can have a page with a different model inside a Resource? Any pointers would be awesome, thanks!
Solution:Jump to solution
I created a new resource and hid it from the navigation menu. It wasn't what I wanted but I had no other way.
7 Replies
What’s the code of your ListCategoryPage?
but the category list is not related to a specific product.
the same as ListProduct. However, I try to change the model in getModel() or in $model and it continues to use the resource model.
I'd try overwriting
$table->query(fn () => ListCategory::query())
and about the create and edit form?
You need to overwrite the the
->form()
method on both pages. But sounds like you rather want another Resource in that caseSolution
I created a new resource and hid it from the navigation menu. It wasn't what I wanted but I had no other way.