Zlatiborac
Zlatiborac
FFilament
Created by Zlatiborac on 10/21/2024 in #❓┊help
Showing the last page as default
Sorry @LeandroFerreira I forgot to say that I have tried that and it will be my option if I don't manage to find a solution to show the last page of the whole set as a default. So if I have, like in my case 561 page, to show that 561st page instead of the first. If it is not possible I will go with the solution you wrote.
4 replies
FFilament
Created by Zlatiborac on 10/15/2024 in #❓┊help
Making 2 version of uploaded image
Thought about that but in the process of image manipulation I have changed the name so I can't check if it exists at the start of execution. I need to think about other approach. Thought that there are more cycles that are not documented when you press submit button, but doesn't look like that. Need to figure another approach then 🙂
18 replies
FFilament
Created by Zlatiborac on 10/15/2024 in #❓┊help
Making 2 version of uploaded image
So @awcodes I did as you suggested, I made Observer class, used Intervention/Image and all is running perfectly except my image manipulation method is being called twice for some reason. I've tried putting it in
public function creating(Post $post)
{
$this->handleImageUpload($post);
}
public function creating(Post $post)
{
$this->handleImageUpload($post);
}
then I read somewhere that it might be the reason for it being called twice, and to change it to
public function saving(Post $post)
{
$this->handleImageUpload($post);
}
public function saving(Post $post)
{
$this->handleImageUpload($post);
}
but it didn't helped. Checked my code and handleImage() is only called once by me, but somehow it runs twice. Generated images are as I wanted them, but I have more than I need. Any ideas?
18 replies
FFilament
Created by Zlatiborac on 10/15/2024 in #❓┊help
Making 2 version of uploaded image
Yes, I am familiar with them, but new to Filament. I was just asking on how to cuple them. Still struggling to find out what is happening inside Filament when I hit submit button, because I belived that it would be easy to do this, fill the form, upload image to temporary folder and when you hit submit you could invoke Intervention to do stuff as you did countless times before. But I was wrong, and it is hard to find some advanced stuff in manual or on web. But, I will try to dig some solution to this. I hope.
18 replies
FFilament
Created by Zlatiborac on 10/15/2024 in #❓┊help
Making 2 version of uploaded image
So only places I can find any ideas about method saveUploadedFileUsing() is the git you gave? Any video/article on how to implement Laravel observer with Filament?
18 replies
FFilament
Created by Zlatiborac on 10/15/2024 in #❓┊help
Making 2 version of uploaded image
I will try the first suggestion. Second I really don't have clue on how to implement 😦
18 replies
FFilament
Created by Zlatiborac on 10/15/2024 in #❓┊help
Making 2 version of uploaded image
I've tried Spatie, but it doesn't suits my current database setup. I went with Intervention/Image, but I can't find any solution using CreatePost and EditPost (what I found is so confusing) I also tried using ->afterStateUpdated (which was most promising), but also failed in the end because I wasn't able to copy the name of thumbnail I've generated to hidden field called 'image_thumbnail' What you suggested, to have 2 different images and upload them in 2 fields is something I wanted to avoid. So, if you have any tips on how to resolve this problem using Intervention I would be grateful. Also, to do everything using ->afterStateUpdated or to do image manipulation after submiting the form (which is the part I found very very little examples or documentation)
18 replies
FFilament
Created by Zlatiborac on 5/18/2024 in #❓┊help
How can I dd() content of the relationship
So after a lot of digging I need to use
mutateRelationshipDataBeforeCreateUsing
mutateRelationshipDataBeforeCreateUsing
to be able to see and manipulate with data that are in relationship. Something like this
return $form
->schema([
Forms\Components\TextInput::make('name')
->required(),

Forms\Components\Fieldset::make('description')
->relationship('productDescription')
->schema([
TextInput::make('description')
->required(),
TextInput::make('price')
->required(),
])
->mutateRelationshipDataBeforeCreateUsing(function (array $data): array {
dd($data);

return $data;
})
]);
return $form
->schema([
Forms\Components\TextInput::make('name')
->required(),

Forms\Components\Fieldset::make('description')
->relationship('productDescription')
->schema([
TextInput::make('description')
->required(),
TextInput::make('price')
->required(),
])
->mutateRelationshipDataBeforeCreateUsing(function (array $data): array {
dd($data);

return $data;
})
]);
Why is this so complicated. What if I wanted to manipulate uploaded image that is also in relationship? That would be hell on earth then
5 replies
FFilament
Created by Zlatiborac on 5/18/2024 in #❓┊help
How can I dd() content of the relationship
Can you try and explain to me like I am a complete noob, how can I dd() every value from my ProductResource. So, where to put dd() since the way I am doing it it just dumps 'name' and not description and price. Let's say that I need to check 'price' how can I fetch only that. I am lost here, and can't find the answer anywhere.
5 replies
FFilament
Created by Zlatiborac on 5/12/2024 in #❓┊help
Manipulation on uploaded image before save
You were thinking on Spatie Media Library ?
9 replies
FFilament
Created by Zlatiborac on 5/12/2024 in #❓┊help
Manipulation on uploaded image before save
Will try it today @Dan Harrin and if I fail 😦 will ask again
9 replies
FFilament
Created by Zlatiborac on 5/12/2024 in #❓┊help
Manipulation on uploaded image before save
Thx Dan 🙂 but I have problem to figure out on how and where to call methods/packages Like in my case I need to get the uploaded file, resize it to 2 different sizes, save both of them with slug name, get those names as vars and put them in database Last night I did some reading and found out that I can use mutateFormDataBeforeCreate and mutateFormDataBeforeSave one on crate page, other on edit. But still struggling on a bit. I will try to find out answers today from reading the manuals
9 replies