Showing AI reviews for avriti-backend
Project AI Score ?
59%
Quality Avg ?
64%
Security Avg ?
45%
Reviews ?
57

Review Result ?

jattin01/avriti-backend · fc385f70
The commit primarily adds a new 'one_line_meaning' attribute across the product model, database, and UI, enhancing product information. It also standardizes item data formatting in order and payment controllers. The changes improve product data completeness and customer communication. However, there is minor risk regarding null handling and no added security hardening evident. The commit message is vague and could better describe the changes made.
Quality ?
85%
Security ?
75%
Business Value ?
80%
Maintainability ?
83%
Issues & Suggested Fixes ?
1AI detects the issue
2Shows file, line, or evidence
3Suggests the fix to apply
Vague
Where commit message
Issue / Evidence vague
Suggested Fix improve the commit message to clearly specify the addition of 'one_line_meaning' and the refactoring of order and payment mail item formatting
Potential Null Access On Comboproduct Find
Where app/Http/Controllers/Api/OrderController.php:194
Issue / Evidence potential null access on ComboProduct find
Suggested Fix add null checks or logs in case of missing records
Potential Null Access On Product Load
Where app/Http/Controllers/Api/OrderController.php:207
Issue / Evidence potential null access on Product load
Suggested Fix validate existence before usage to reduce bug risk
Potential Null Access On Comboproduct Find
Where app/Http/Controllers/Api/RazorpayController.php:231
Issue / Evidence potential null access on ComboProduct find
Suggested Fix add null checks or error handling
Potential Null Access On Product Load
Where app/Http/Controllers/Api/RazorpayController.php:244
Issue / Evidence potential null access on Product load
Suggested Fix add verification before dereferencing to avoid exceptions
Missing Validation
Where app/Http/Controllers/AdminProductController.php:131
Issue / Evidence validation could be stricter
Suggested Fix consider sanitizing input for 'one_line_meaning' to prevent injection risks
Input Field
Where resources/views/admin/partials/product-form.blade.php:444
Issue / Evidence input field
Suggested Fix add maxlength attribute to match backend max:255 validation
Code Change Preview · app/Http/Controllers/AdminProductController.php ?
Removed / Before Commit
- 'sold_as' => ['nullable', 'array'],
- 'sold_as.*' => ['nullable', 'string', 'max:255'],
- 'country_of_origin' => ['nullable', 'string', 'max:255'],
- 'storage_instructions' => ['nullable', 'string'],
- 'disclaimer' => ['nullable', 'string'],
- 'important_notes' => ['nullable', 'string'],
- 'fragrance' => $this->cleanRows($validated['fragrance'] ?? []),
- 'sold_as' => $this->cleanRows($validated['sold_as'] ?? []),
- 'country_of_origin' => $validated['country_of_origin'] ?? null,
- 'storage_instructions' => $validated['storage_instructions'] ?? null,
- 'disclaimer' => $validated['disclaimer'] ?? null,
- 'important_notes' => $validated['important_notes'] ?? null,
Added / After Commit
+ 'sold_as' => ['nullable', 'array'],
+ 'sold_as.*' => ['nullable', 'string', 'max:255'],
+ 'country_of_origin' => ['nullable', 'string', 'max:255'],
+                 'one_line_meaning' => ['nullable', 'string', 'max:255'],
+ 'storage_instructions' => ['nullable', 'string'],
+ 'disclaimer' => ['nullable', 'string'],
+ 'important_notes' => ['nullable', 'string'],
+ 'fragrance' => $this->cleanRows($validated['fragrance'] ?? []),
+ 'sold_as' => $this->cleanRows($validated['sold_as'] ?? []),
+ 'country_of_origin' => $validated['country_of_origin'] ?? null,
+             'one_line_meaning' => $validated['one_line_meaning'] ?? null,
+ 'storage_instructions' => $validated['storage_instructions'] ?? null,
+ 'disclaimer' => $validated['disclaimer'] ?? null,
+ 'important_notes' => $validated['important_notes'] ?? null,
Removed / Before Commit
- // clear cart after successful order
- CartItem::where('customer_id', $customerId)->delete();
- 
- // email send last mein
- if ($billingEmail) {
- try {
- 'tax_breakup'     => $taxResult['breakup'],
- 'shipping'        => $shippingCharge,
- 'total'           => $totalAmount,
-                 'items'           => $request->input('items', []),
- ]));
- Log::info('COD order email sent', ['order_number' => $orderNumber, 'email' => $billingEmail]);
- } catch (\Throwable $e) {
- ], 201);
- }
- 
- private function decrementStock(array $items): void
- {
Added / After Commit
+ // clear cart after successful order
+ CartItem::where('customer_id', $customerId)->delete();
+ 
+         $mailItems = $this->formatMailItems($items);
+ 
+ // email send last mein
+ if ($billingEmail) {
+ try {
+ 'tax_breakup'     => $taxResult['breakup'],
+ 'shipping'        => $shippingCharge,
+ 'total'           => $totalAmount,
+                 'items'           => $mailItems,
+ ]));
+ Log::info('COD order email sent', ['order_number' => $orderNumber, 'email' => $billingEmail]);
+ } catch (\Throwable $e) {
+ ], 201);
+ }
+ 
Removed / Before Commit
- // 5. Cart clear
- CartItem::where('customer_id', $customerId)->delete();
- 
- // 6. Email send
- if ($billingEmail) {
- try {
- 'tax_breakup'         => $taxResult['breakup'],
- 'shipping'            => $shippingCharge,
- 'total'               => $request->input('total', 0),
-                     'items'               => $request->input('items', []),
- ]));
- Log::info('Razorpay order email sent', ['order_number' => $orderNumber, 'email' => $billingEmail]);
- } catch (\Throwable $e) {
- ]);
- }
- 
- private function decrementStock(array $items): void
- {
Added / After Commit
+ // 5. Cart clear
+ CartItem::where('customer_id', $customerId)->delete();
+ 
+         $mailItems = $this->formatMailItems($request->input('items', []));
+ 
+ // 6. Email send
+ if ($billingEmail) {
+ try {
+ 'tax_breakup'         => $taxResult['breakup'],
+ 'shipping'            => $shippingCharge,
+ 'total'               => $request->input('total', 0),
+                     'items'               => $mailItems,
+ ]));
+ Log::info('Razorpay order email sent', ['order_number' => $orderNumber, 'email' => $billingEmail]);
+ } catch (\Throwable $e) {
+ ]);
+ }
+ 
Removed / Before Commit
- 'fragrance',
- 'sold_as',
- 'country_of_origin',
- 'storage_instructions',
- 'disclaimer',
- 'important_notes',
Added / After Commit
+ 'fragrance',
+ 'sold_as',
+ 'country_of_origin',
+         'one_line_meaning',
+ 'storage_instructions',
+ 'disclaimer',
+ 'important_notes',
Removed / Before Commit

                                                
Added / After Commit
+ <?php
+ 
+ use Illuminate\Database\Migrations\Migration;
+ use Illuminate\Database\Schema\Blueprint;
+ use Illuminate\Support\Facades\Schema;
+ 
+ return new class extends Migration
+ {
+     /**
+      * Run the migrations.
+      */
+     public function up(): void
+     {
+         Schema::table('products', function (Blueprint $table) {
+             $table->string('one_line_meaning')->nullable()->after('country_of_origin');
+         });
+     }
+ 
Removed / Before Commit
- @enderror
- </div>
- 
- <div class="lg:col-span-3 py-5">
- <label class="block text-sm font-semibold text-gray-700 mb-2">Storage Instructions</label>
- <div id="editor-storage_instructions-{{ $formInstanceId }}" class="rounded-2xl border border-gray-300 bg-white" style="min-height:90px" data-quill-editor></div>
- @enderror
- </div>
- 
-   <div class="lg:col-span-3 py-5">
- <label class="block text-sm font-semibold text-gray-700 mb-2">Disclaimer</label>
- <div id="editor-disclaimer-{{ $formInstanceId }}" class="rounded-2xl border border-gray-300 bg-white" style="min-height:90px" data-quill-editor></div>
- <textarea name="disclaimer" id="input-disclaimer-{{ $formInstanceId }}" class="hidden" data-quill-input>{{ old('disclaimer', $product?->disclaimer) }}</textarea>
- @enderror
- </div>
- 
-   <div class="lg:col-span-3 py-5">
- <label class="block text-sm font-semibold text-gray-700 mb-2">Important Notes</label>
Added / After Commit
+ @enderror
+ </div>
+ 
+   <div class="lg:col-span-3">
+     <label class="block text-sm font-semibold text-gray-700 mb-2">One-Line Meaning</label>
+     <input type="text" name="one_line_meaning" value="{{ old('one_line_meaning', $product?->one_line_meaning) }}" placeholder="e.g. A symbol of clarity and protection" class="w-full h-12 px-4 border border-gray-300 rounded-md outline-none focus:ring-2 focus:ring-blue-400 focus:border-transparent" />
+     @error('one_line_meaning')
+       <p data-error-message class="mt-2 text-xs font-medium text-red-500">{{ $message }}</p>
+     @enderror
+   </div>
+ 
+ <div class="lg:col-span-3 py-5">
+ <label class="block text-sm font-semibold text-gray-700 mb-2">Storage Instructions</label>
+ <div id="editor-storage_instructions-{{ $formInstanceId }}" class="rounded-2xl border border-gray-300 bg-white" style="min-height:90px" data-quill-editor></div>
+ @enderror
+ </div>
+ 
+   <div class="lg:col-span-3 py-5 mt-[22px]">
Removed / Before Commit
- <p class="mt-2 text-sm text-slate-500">{{ $subtitle }}</p>
- </div>
- 
-             <div class="rounded-[28px] border border-slate-200 bg-slate-50 p-6">
-               <div class="space-y-4">
- <div class="flex items-center justify-between gap-4 text-sm text-slate-600">
- <span>Username</span>
- <span class="font-semibold text-slate-900">{{ $username }}</span>
- </div>
- </div>
- 
-           <div class="rounded-[28px] border border-slate-200 bg-slate-50 p-6">
- <div class="flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between">
- <div class="text-sm font-semibold text-slate-700">Social Media:</div>
- <div class="flex flex-wrap items-center gap-3">
- <a href="#" class="inline-flex h-11 w-11 items-center justify-center rounded-2xl border border-slate-200 bg-white text-slate-700 shadow-sm hover:bg-slate-100"><i class="fab fa-whatsapp"></i></a>
- </div>
- </div>
Added / After Commit
+ <p class="mt-2 text-sm text-slate-500">{{ $subtitle }}</p>
+ </div>
+ 
+             <div class="rounded-[28px] border border-slate-200 bg-slate-50 p-6 ]">
+               <div class="space-y-8">
+ <div class="flex items-center justify-between gap-4 text-sm text-slate-600">
+ <span>Username</span>
+ <span class="font-semibold text-slate-900">{{ $username }}</span>
+ </div>
+ </div>
+ 
+           <!-- <div class="rounded-[28px] border border-slate-200 bg-slate-50 p-6">
+ <div class="flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between">
+ <div class="text-sm font-semibold text-slate-700">Social Media:</div>
+ <div class="flex flex-wrap items-center gap-3">
+ <a href="#" class="inline-flex h-11 w-11 items-center justify-center rounded-2xl border border-slate-200 bg-white text-slate-700 shadow-sm hover:bg-slate-100"><i class="fab fa-whatsapp"></i></a>
+ </div>
+ </div>
Removed / Before Commit
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <tr>
- <td style="padding:14px 20px; border-bottom:1px solid #f0f0f0; font-size:13px; color:#444;">
- <span style="color:#888; display:inline-block; width:110px;">Web Address:</span>
-               <span style="color:#1a1a1a;">{{ config('app.url') }}</span>
- </td>
- </tr>
- <tr>
Added / After Commit
+ @php($frontendUrl = rtrim(env('FRONTEND_URL', config('app.url')), '/'))
+ <!DOCTYPE html>
+ <html lang="en">
+ <head>
+ <tr>
+ <td style="padding:14px 20px; border-bottom:1px solid #f0f0f0; font-size:13px; color:#444;">
+ <span style="color:#888; display:inline-block; width:110px;">Web Address:</span>
+               <span style="color:#1a1a1a;">{{ $frontendUrl }}</span>
+ </td>
+ </tr>
+ <tr>
Removed / Before Commit
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <tr>
- <td style="padding:0 40px 20px;">
- <div style="text-align:center;">
-           <a href="https://avriti.digitalmission.in/" style="display:inline-block;text-decoration:none;font-family:'Basic',Arial,sans-serif;text-transform:uppercase;background:#0b3dba; padding:10px 30px; border-radius:10px; color:#fff; border:1px solid #0b3dba; margin:0 auto;">Visit Avriti</a>
- </div>
- </td>
- </tr>
Added / After Commit
+ @php($frontendUrl = rtrim(env('FRONTEND_URL', config('app.url')), '/'))
+ <!DOCTYPE html>
+ <html lang="en">
+ <head>
+ <tr>
+ <td style="padding:0 40px 20px;">
+ <div style="text-align:center;">
+           <a href="{{ $frontendUrl }}" style="display:inline-block;text-decoration:none;font-family:'Basic',Arial,sans-serif;text-transform:uppercase;background:#0b3dba; padding:10px 30px; border-radius:10px; color:#fff; border:1px solid #0b3dba; margin:0 auto;">Visit Avriti</a>
+ </div>
+ </td>
+ </tr>