Filament Custom Page always shows admin panel navigation
Filament Custom Page 'ListProductSellers' in my Buyer Panel always shows results with Admin panel sidebar navigation. My expectation is to show results with the Buyer Panel sidebar navigation.
This page is not associated with any resource. I am defining its route in web.php.
In my ListProductSellers class, I have a table for an Eloquent relationship. I am calling this Custom Page from another livewire component blade file using a filament link.
I have attached my ListProductSeller class code. Please let me know where I am wrong.
I have attached my ListProductSeller class code. Please let me know where I am wrong.
Solution:Jump to solution
Bingo. I got it working. Debugging shows that whenever a Filament Custom Page gets called from anywhere as a URL, the URL parameters passed by the caller are not used for automatically Initialise using the mount('ID or entire Instance as parameter') method in the Filament Custom Page class.
URL parameters are present in a Filament Custom Page as a Super Global Variable which can be assessed
Using $_GET[‘one_of the_url_parameters’] // You can pass ID as a parameter.
...
17 Replies
This page is not associated with any resource. I am defining its route in web.php.Why are you doing it like this?
I could be wrong. I didn't associate this with any resources because I felt my Buyer panel does not have any resources currently. My Product and Seller resources are with the Admin panel. The buyer panel has a separate authentication guard. I don't know what is the right way to call this private page with query parameters as a link from other livewire components. I am fine not using the route in web.php.
You don't need to add it to resources but you can still register is via the panel
Please guide me how.
If you created it for the Buyer Panel it should be in the
Pages
folder and auto registered if you have ->discoverPages()
on your panel config.Yes it is present in filament->buyer->pages folder. I dont have any problem if i dont have any query parameter. It does not even ask route definition in web.php. But with query parameter, I get route definition error if I dont use route in web.php
I have now deleted my route from web.php. Using the following link to access my Filament Custom Page. But I am repeatedly getting folowing error: Illuminate\Contracts\Container\BindingResolutionException
Unable to resolve dependency [Parameter #0 [ <required> $product_id ]] in class App\Filament\Buyer\Pages\ListProductSellers . I using follwoing mount method in ListProductSellers
Does your slug match the argument name?
I have not touched my slug. Itis default generated by Custom page.
Yes, but you touched the
mount()
method. I think slug and mount must matchYou mean adding protected static ?string $slug = '{product_id}' in Custom page class. This gives error to me. Cannot assign null to property App\Filament\Buyer\Pages\ListProductSellers::$product of type App\Models\Product. This may be an error in Public Product $product assignment. How to match slug with mount. I am cluless hwo to proceed?
Can you share the updated code?
Attched My custom Page class. Follwing link I am using from another component blade file to access my custom page
The error above says, that
Product::find($product_id);
is null. Did you check what $product_id
is?I am clueless why Product::find($produt_id) returing null. I changed my mount a bit. Instead of passing $product_id, I am now passing $product. In the link route now looks like below: . All my error is gone but I dont have any table data. It says no sellers where as I can clearly see I have a list. I have following url showling in broser. http://localhost/buyer/list-product-sellers?product=381 . You can see it is clearly having product ID 381. In my original issue using route in web.php I have everything right but with admin panel sidebar.
This error null occurs only when I try to change the slug and assign as slug = {$id}. When slug is commented out, I am repeatedly getting folowing error when link uses product ID as parameter: Illuminate\Contracts\Container\BindingResolutionException
Unable to resolve dependency [Parameter #0 [ <required> $product_id ]] in class App\Filament\Buyer\Pages\ListProductSellers . As mentioned when I change parameter from product_id to product and change my mount accordingly. Then error is gone but my page has not table result data.
When slug is commented out, I am repeatedly getting folowing error when link uses product ID as parameter:Which makes sense, as it cannot resolve that param from your url
As mentioned when I change parameter from product_id to product and change my mount accordingly. Then error is gone but my page has not table result data.What's the content of
$this->product
and $this->product->mainsellers()
? Did you debug this?I got this code running in a modal containing Livewire component code. No changes. Just implemented the Livewire component instead of the filament custom page. This component is triggered through Modal action. The custom page is receiving an empty mount. I don't know why. In fact, I am unable to implement any Filament custom pages which need a mount parameter.
Solution
Bingo. I got it working. Debugging shows that whenever a Filament Custom Page gets called from anywhere as a URL, the URL parameters passed by the caller are not used for automatically Initialise using the mount('ID or entire Instance as parameter') method in the Filament Custom Page class.
URL parameters are present in a Filament Custom Page as a Super Global Variable which can be assessed
Using $_GET[‘one_of the_url_parameters’] // You can pass ID as a parameter.
Do not create route in web.php for Filament Custom Pages if used for logged-in users. Initialise using mount() like below:
Sharing my entire code in the attachment. This is applicable anywhere wherever one wants to call the Custom Filament Page from a URL