Skip to content

Commit a23aeae

Browse files
authored
Merge pull request #163 from velstorelabs/feature/admin-validation-v2
added review submission and wishlist multi-lingual translations
2 parents 85c0a84 + 48c9676 commit a23aeae

File tree

24 files changed

+289
-11
lines changed

24 files changed

+289
-11
lines changed

app/Http/Controllers/Store/CategoryController.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ public function show($slug, Request $request)
2424
'reviews',
2525
'images',
2626
])
27+
->withCount(['reviews' => function ($q) {
28+
$q->where('is_approved', 1);
29+
}])
30+
->withAvg(['reviews' => function ($q) {
31+
$q->where('is_approved', 1);
32+
}], 'rating')
2733
->where('status', 1)
2834
->where('category_id', $category->id);
2935

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\Store;
4+
5+
use App\Http\Controllers\Controller;
6+
use App\Models\ProductReview;
7+
use Illuminate\Http\Request;
8+
use Illuminate\Support\Facades\Auth;
9+
10+
class ReviewController extends Controller
11+
{
12+
public function store(Request $request)
13+
{
14+
$request->validate([
15+
'product_id' => 'required|exists:products,id',
16+
'rating' => 'required|integer|min:1|max:5',
17+
'review' => 'nullable|string|max:500',
18+
]);
19+
20+
// Check if already reviewed
21+
if (ProductReview::where('product_id', $request->product_id)
22+
->where('customer_id', Auth::guard('customer')->id())
23+
->exists()) {
24+
return back()->with('error', 'You have already reviewed this product.');
25+
}
26+
27+
ProductReview::create([
28+
'customer_id' => Auth::guard('customer')->id(),
29+
'product_id' => $request->product_id,
30+
'rating' => $request->rating,
31+
'review' => $request->review,
32+
'is_approved' => 1,
33+
]);
34+
35+
return back()->with('success', 'Thank you! Your review is now live.');
36+
}
37+
}

resources/lang/ar/store.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,4 +158,11 @@
158158
'no_products_found' => 'لا توجد منتجات في هذه الفئة.',
159159
'add_to_cart_success' => 'تمت إضافة المنتج إلى السلة بنجاح!',
160160
],
161+
162+
'wishlist' => [
163+
'title' => 'قائمتي المفضلة',
164+
'empty' => 'قائمتك المفضلة فارغة.',
165+
'reviews' => 'التقييمات',
166+
'add_to_cart' => 'أضف إلى السلة',
167+
],
161168
];

resources/lang/de/store.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,4 +158,11 @@
158158
'no_products_found' => 'Keine Produkte in dieser Kategorie gefunden.',
159159
'add_to_cart_success' => 'Erfolgreich zum Warenkorb hinzugefügt!',
160160
],
161+
162+
'wishlist' => [
163+
'title' => 'Meine Wunschliste',
164+
'empty' => 'Deine Wunschliste ist leer.',
165+
'reviews' => 'Bewertungen',
166+
'add_to_cart' => 'In den Warenkorb',
167+
],
161168
];

resources/lang/en/store.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,4 +159,11 @@
159159
'no_products_found' => 'No products found in this category.',
160160
'add_to_cart_success' => 'Added to cart successfully!',
161161
],
162+
163+
'wishlist' => [
164+
'title' => 'My Wishlist',
165+
'empty' => 'Your wishlist is empty.',
166+
'reviews' => 'Reviews',
167+
'add_to_cart' => 'Add to Cart',
168+
],
162169
];

resources/lang/es/store.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,4 +158,11 @@
158158
'no_products_found' => 'No se encontraron productos en esta categoría.',
159159
'add_to_cart_success' => '¡Producto añadido al carrito con éxito!',
160160
],
161+
162+
'wishlist' => [
163+
'title' => 'Mi lista de deseos',
164+
'empty' => 'Tu lista de deseos está vacía.',
165+
'reviews' => 'Reseñas',
166+
'add_to_cart' => 'Agregar al carrito',
167+
],
161168
];

resources/lang/fa/store.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,4 +158,11 @@
158158
'no_products_found' => 'هیچ محصولی در این دسته یافت نشد.',
159159
'add_to_cart_success' => 'محصول با موفقیت به سبد خرید اضافه شد!',
160160
],
161+
162+
'wishlist' => [
163+
'title' => 'لیست علاقه‌مندی‌های من',
164+
'empty' => 'لیست علاقه‌مندی‌های شما خالی است.',
165+
'reviews' => 'نظرات',
166+
'add_to_cart' => 'افزودن به سبد خرید',
167+
],
161168
];

resources/lang/fr/store.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,4 +158,11 @@
158158
'no_products_found' => 'Aucun produit trouvé dans cette catégorie.',
159159
'add_to_cart_success' => 'Ajouté au panier avec succès !',
160160
],
161+
162+
'wishlist' => [
163+
'title' => 'Ma liste de souhaits',
164+
'empty' => 'Votre liste de souhaits est vide.',
165+
'reviews' => 'Avis',
166+
'add_to_cart' => 'Ajouter au panier',
167+
],
161168
];

resources/lang/hi/store.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,4 +158,11 @@
158158
'no_products_found' => 'इस श्रेणी में कोई उत्पाद नहीं मिला।',
159159
'add_to_cart_success' => 'सफलतापूर्वक कार्ट में जोड़ा गया!',
160160
],
161+
162+
'wishlist' => [
163+
'title' => 'मेरी इच्छासूची',
164+
'empty' => 'आपकी इच्छासूची खाली है।',
165+
'reviews' => 'समीक्षाएँ',
166+
'add_to_cart' => 'कार्ट में जोड़ें',
167+
],
161168
];

resources/lang/id/store.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,4 +158,11 @@
158158
'no_products_found' => 'Tidak ada produk ditemukan dalam kategori ini.',
159159
'add_to_cart_success' => 'Berhasil ditambahkan ke keranjang!',
160160
],
161+
162+
'wishlist' => [
163+
'title' => 'Daftar Keinginan Saya',
164+
'empty' => 'Daftar keinginan Anda kosong.',
165+
'reviews' => 'Ulasan',
166+
'add_to_cart' => 'Tambah ke Keranjang',
167+
],
161168
];

0 commit comments

Comments
 (0)