composer require baks-dev/products-review
php bin/console baks:assets:install
php bin/console doctrine:migrations:diff
php bin/console doctrine:migrations:migrate
public/vendor/baks/products-review.@include('products-review::review.form')) in a product view.config/products-review.php (auto-generated after installation) for settings like:
app/Models/ProductsReview/ (or vendor namespace) for:
Review.php (core model).ReviewRating.php (if ratings are supported).database/migrations/ for schema changes (e.g., reviews, review_ratings tables).php bin/console list baks
Example: Moderation tools like baks:review:approve.@include('products-review::review.form', ['productId' => $product->id])
ProductsReviewController) or form request (e.g., StoreReviewRequest). Extend if needed:
use Baks\ProductsReview\Http\Requests\StoreReviewRequest;
public function store(StoreReviewRequest $request) {
// Custom logic (e.g., pre-submission hooks)
$review = $request->review();
// ...
}
@foreach($product->reviews as $review)
@include('products-review::review.card', ['review' => $review])
@endforeach
StoreReviewRequest) or extend the Review model’s create() method.$reviews = \Baks\ProductsReview\Models\Review::with('user', 'ratings')->where('product_id', $product->id)->get();
$review->update(['content' => 'Updated text']);
$review->delete(); // or forceDelete()
$review->ratings()->create(['value' => 5, 'user_id' => auth()->id()]);
$average = $review->ratings()->avg('value');
$pending = \Baks\ProductsReview\Models\Review::where('status', 'pending')->get();
php bin/console baks:review:approve {reviewId}
php bin/console baks:review:reject {reviewId}
Or programmatically:
$review->approve(); // or reject()
Customize Templates: Override Blade templates by publishing them:
php artisan vendor:publish --tag=products-review-views
Then edit files in resources/views/vendor/products-review/.
Extend CSS/JS: Publish assets and extend:
php artisan vendor:publish --tag=products-review-assets
Add custom styles to public/vendor/baks/products-review/css/app.css.
Baks\ProductsReview\ProductsReviewServiceProvider).
$this->app->extend('review.moderator', function ($moderator) {
return new CustomModerator($moderator);
});
ReviewCreated, ReviewApproved):
\Baks\ProductsReview\Events\ReviewCreated::class => [ReviewListener::class, 'handle'],
Route::middleware(['auth', 'verified'])->group(function () {
// Review routes
});
Schema::table('reviews', function (Blueprint $table) {
$table->string('custom_field')->nullable();
});
Schema::table('review_ratings', function (Blueprint $table) {
$table->index(['review_id', 'user_id']);
});
Route::post('/api/reviews', [ReviewController::class, 'store']);
axios.post('/api/reviews', { content: 'Review text' }, {
headers: { 'Authorization': `Bearer ${user.token}` }
});
public function testReviewCreation()
{
$this->actingAs($user)
->post('/reviews', ['product_id' => 1, 'content' => 'Great product!'])
->assertRedirect('/products/1');
}
public function testModerationWorkflow()
{
$review = \Baks\ProductsReview\Models\Review::factory()->create(['status' => 'pending']);
$this->artisan('baks:review:approve', ['id' => $review->id])
->assertExitCode(0);
$this->assertEquals('approved', $review->fresh()->status);
}
Schema Conflicts:
reviews or products tables.Schema::create('baks_reviews', function (Blueprint $table) {
// ...
});
doctrine:migrations:diff in a staging DB first to preview changes.Asset Overwrites:
public/vendor/.Moderation Logic:
$this->app->singleton('review.moderator', function () {
return new CustomModerator();
});
Missing API:
Route::apiResource('reviews', ReviewApiController::class);
PHP 8.4+ Requirements:
spatie/laravel-php-version).No Frontend Framework:
Console Command Errors:
php bin/console baks:assets:install -v
tail -f storage/logs/laravel.log | grep doctrine
Migration Failures:
php bin/console doctrine:migrations:rollback
php bin/console doctrine:migrations:migrate
--pretend to dry-run:
php bin/console doctrine:migrations:diff --pretend
Review Submission Issues:
$request->validate([
'content' => 'required|string|max:2000',
'rating' => 'required|integer|between:1,5',
]);
How can I help you explore Laravel packages today?