Action for PDF and JPG preview
Hi, I need to create a preview action to display a preview of PDF and JPG files in a modal. How should I proceed, is there something ready in Filament? Thanks.
12 Replies
It worked, thank you. But I can't make the modal's width as wide as possible. I've already tried several possible values within MaxWith::FourExtraLarge, Full, LG, SM and others and it only stays at this width. I've already given npm run build several times. Is there anything to be done?
Show your action code (
modalWidth
). In your message you write MaxWith
but I assume your code has MaxWidth
?That's right. Any value I put in the modalWidth method will always be the same size. I've already run npm run builder several times and it's still the same.
Solution
Remove
->requiresConfirmation(false)
and try againYou use it (
->requiresConfirmation()
) when you have an action defined that you only want to run after a confirmation is given. In your case it is not applicable (and you wouldn't set it to false but just omit it). Apparently when you do use it a default width is applied (not sure if that is a bug or intended behavior).url is error
Argument #1 ($record) must be of type Blueprint\Contracts\Model
Not sure how we got here after the discussion about the modal width. Anyway this errors means you are using the wrong Model class in the function. This should be Eloquent’s model class, not the contract class (so the
Model
in the fn(Model $record)
is the wrong class).what should I do Sir? Do you have any sample code to view the uploaded PDF file? Because this is the of my problem to my project. Hope your quick response. Thank you Sir. God bless.
At the top of your file replace
use Blueprint\Contracts\Model;
with use Illuminate\Database\Eloquent\Model;
But next time post a new #❓┊help question as your question is completely unrelated to OP's question.