bionary
bionary
FFilament
Created by bionary on 12/11/2024 in #❓┊help
Can I sort table on non-column data
Ahhh it's getting late. I had a fixed sort on the query in...
public static function getEloquentQuery(): Builder
{
return parent::getEloquentQuery()
... sorting here duh....
public static function getEloquentQuery(): Builder
{
return parent::getEloquentQuery()
... sorting here duh....
All is right with my Filament universe at the moment 🙂
12 replies
FFilament
Created by bionary on 12/11/2024 in #❓┊help
Can I sort table on non-column data
Not directly. It's a calculated value based on a collection via a relationship. As in...give me the olded "past due date" related to this client and calculate that date from today in days (integer) I went back to my original idea and am using a Model Event. I seem to use those a lot and it's easy to forget about their magic when maintaining stuff later. The columns are written correctly but oddly filament is not sorting correctly. The new column does have negative numbers and nulls in there. Is that troublesome for Filament to sort?
12 replies
FFilament
Created by bionary on 12/11/2024 in #❓┊help
Can I sort table on non-column data
Well that was a deep but unsuccessful rabbit hole. It turns out I cannot use virtual columns in this instance because a virtual column (MySQL) cannot reference data from other tables.
12 replies
FFilament
Created by bionary on 12/11/2024 in #❓┊help
Can I sort table on non-column data
Okay looking at this here: https://laraveldaily.com/post/virtual-db-columns-laravel-migrations-mysql I think you might be onto something Adam!
12 replies
FFilament
Created by bionary on 12/11/2024 in #❓┊help
Can I sort table on non-column data
I originally started planning a date based column...but making sure it reflected information based on other table changes was a nightmare.
12 replies
FFilament
Created by bionary on 12/11/2024 in #❓┊help
Can I sort table on non-column data
Hi Adam! hmmm never new virtual column was a thing.
12 replies
FFilament
Created by bionary on 6/26/2024 in #❓┊help
Anybody find a decent solution for table images to a lightbox?
@_andypeacock Your solution looks a lot smarter/cleaner than what I came up with. Thank you. I was doing something similar but packing it all in the Filament Resource like this:
SpatieMediaLibraryImageColumn::make($dotNotationMediaPath)
->action(
Actions\Action::make($dotNotationMediaPath)
->modalHeading(false)
->extraModalWindowAttributes(['class'=>'justify-center h-[calc(100vh-100px)]', 'style'=>'flex-direction:inherit'])
->modalContent(function($record){
$imageUrl = $record?->getFirstMedia($collection)?->getUrl('preview');
return new HtmlString("<img src='$imageUrl' class='object-scale-down max-h-full p-4'>");
})
->modalFooterActions(fn() => [])
SpatieMediaLibraryImageColumn::make($dotNotationMediaPath)
->action(
Actions\Action::make($dotNotationMediaPath)
->modalHeading(false)
->extraModalWindowAttributes(['class'=>'justify-center h-[calc(100vh-100px)]', 'style'=>'flex-direction:inherit'])
->modalContent(function($record){
$imageUrl = $record?->getFirstMedia($collection)?->getUrl('preview');
return new HtmlString("<img src='$imageUrl' class='object-scale-down max-h-full p-4'>");
})
->modalFooterActions(fn() => [])
I never quite found a way to scale the image properly. Even with my custom class added to the image, it was still not scaling properly and would get cut off if the aspect ratio was extreme. Also the white border around the image was never equal/balanced...but my tailwind skills are junk. Can't wait to try your solution, thanks!
10 replies
FFilament
Created by bionary on 8/21/2024 in #❓┊help
Show First image: SpatieMediaLibraryImageColumn
thank you
15 replies
FFilament
Created by bionary on 8/21/2024 in #❓┊help
Show First image: SpatieMediaLibraryImageColumn
Since all I need is the first image (luckily) I'm all good with ->limit(1) for now
15 replies
FFilament
Created by bionary on 8/21/2024 in #❓┊help
Show First image: SpatieMediaLibraryImageColumn
indeed.
15 replies
FFilament
Created by bionary on 8/21/2024 in #❓┊help
Show First image: SpatieMediaLibraryImageColumn
I was thinking I could get clever and use field: collection_name to isolate an image...but that feels a bit hacky to me.
15 replies
FFilament
Created by bionary on 8/21/2024 in #❓┊help
Show First image: SpatieMediaLibraryImageColumn
As in pick a different image based on some values I have stored in the custom_properties field of the table.
15 replies
FFilament
Created by bionary on 8/21/2024 in #❓┊help
Show First image: SpatieMediaLibraryImageColumn
Is there a reason ->getStateUsing() doesn't work? in my case I'm all good...for now, but what if I wanted to get a bit more choosy with which image shows...
15 replies
FFilament
Created by bionary on 8/21/2024 in #❓┊help
Show First image: SpatieMediaLibraryImageColumn
It works perfectly, thanks
15 replies
FFilament
Created by bionary on 8/21/2024 in #❓┊help
Show First image: SpatieMediaLibraryImageColumn
just found that!
15 replies
FFilament
Created by bionary on 7/15/2024 in #❓┊help
Spatie Media Library Conversion Quality NOT Applied
I'll post a bug at Spaties Github
11 replies
FFilament
Created by bionary on 7/15/2024 in #❓┊help
Spatie Media Library Conversion Quality NOT Applied
Roger that.
11 replies
FFilament
Created by bionary on 7/15/2024 in #❓┊help
Spatie Media Library Conversion Quality NOT Applied
@awcodes Adam, I was going to file a bug at https://github.com/filamentphp/spatie-laravel-media-library-plugin but it is READ ONLY.
11 replies
FFilament
Created by bionary on 7/15/2024 in #❓┊help
Spatie Media Library Conversion Quality NOT Applied
fyi: there was talk about a related bug here: https://github.com/spatie/laravel-medialibrary/issues/3502
11 replies
FFilament
Created by bionary on 7/15/2024 in #❓┊help
Spatie Media Library Conversion Quality NOT Applied
The simplified version looks like this:
public function handle(ConversionHasBeenCompletedEvent $event): void
{
$media = $event->media;

if($media->mime_type == 'image/png'){

$conversionName = $event->conversion->getName();

//Replace with compressed version
$image = Image::load($media->getPath($event->conversion->getName()))
->quality(65)
->optimize()
->save();
}
}
public function handle(ConversionHasBeenCompletedEvent $event): void
{
$media = $event->media;

if($media->mime_type == 'image/png'){

$conversionName = $event->conversion->getName();

//Replace with compressed version
$image = Image::load($media->getPath($event->conversion->getName()))
->quality(65)
->optimize()
->save();
}
}
11 replies