File: /var/www/limestate-admin/app/Repositories/AttachmentRepository.php
<?php
declare(strict_types=1);
namespace App\Repositories;
use App\Models\Attachment\Attachment;
use Illuminate\Support\LazyCollection;
class AttachmentRepository
{
public static array $availableExtension = ['png', 'jpg', 'jpeg'];
public static function getImagesAvailableToThumbnail(): LazyCollection
{
return Attachment::query()->whereRaw("LOWER(extension) IN ('" . join("','", self::$availableExtension) . "')")->cursor();
}
public static function getThumbnailPath(Attachment $attachment, string $type): string
{
return storage_path('/app/public/thumbs/' . $attachment->path . $attachment->name . '_' . $type . '.' . $attachment->extension);
}
}