Laravel Review Rateable v2.2.0
Version 2.2.0 adds optional image attachments to reviews while keeping the package headless and backward-compatible.
Applications retain complete control over their upload interface, gallery, modal, and styling. The package manages image metadata, ordering, storage, URLs, validation limits, and cleanup.
What's new
- Attach multiple images to a review.
- Preserve configurable image ordering.
- New
images()relationship. - New
addImage()andaddImages()methods. - Remove images with
removeImage(). - Change image order with
reorderImages(). - Configure the storage disk and image directories.
- Configure maximum image count and file size.
- Configure allowed MIME types.
- Access original and thumbnail URLs.
- Fall back to the original URL when no thumbnail is provided.
- Safely remove stored files after database commits.
- Clean up partial uploads when a batch operation fails.
- Eager load images alongside reviews and ratings.
- Amazon-style thumbnail gallery and modal example added to the documentation.
Optional installation
Review images are completely optional. Existing applications do not receive an additional database table unless the image migration is explicitly published.
php artisan vendor:publish \
--provider="Codebyray\ReviewRateable\ReviewRateableServiceProvider" \
--tag=review-images-migrations
php artisan migrateWhen using Laravel's public filesystem disk, ensure the storage link exists:
php artisan storage:linkExample
$review = $product->addReview([
'review' => 'Excellent product.',
'ratings' => [
'overall' => 5,
],
], auth()->id());
$review->addImages([
$request->file('front'),
[
'image' => $request->file('back'),
'alt_text' => 'Rear connections',
],
]);Applications may provide their own generated thumbnail:
$review->addImage(
image: $request->file('image'),
altText: 'Front view',
thumbnail: $generatedThumbnail,
);Backward compatibility
This release contains no intentional breaking changes:
- Existing review and rating APIs remain compatible.
- The public service contract is unchanged.
- Existing migration publishing behavior is unchanged.
- Images remain opt-in.
- No frontend framework is required.
- No image-processing or Spatie Media Library dependency was added.
- PHP 8.1+ and Laravel 10-13 remain supported.
Testing
The release is covered by tests for image storage, ordering, validation, URL generation, ownership, failed uploads, cleanup, database rollbacks, eager loading, and optional migration publishing across supported Laravel versions.