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

Review Result ?

jattin01/avriti-backend · caf16142
This commit adds support for service details including call types and tier fields with validation, migration, and API updates. The code improves the service detail data model and its handling in various controllers, enhancing business functionality. Validation exists for tier SKUs and input fields, and images are safely stored. However, some error handling and input sanitation could be strengthened, and more precise commit messages would help clarity.
Quality ?
85%
Security ?
80%
Business Value ?
90%
Maintainability ?
85%
Issues & Suggested Fixes ?
1AI detects the issue
2Shows file, line, or evidence
3Suggests the fix to apply
Insufficient Detail
Where commit message
Issue / Evidence insufficient detail
Suggested Fix improve commit message to better describe purpose and scope of changes, e.g., mention updating service details with call_type and tier_fields
Missing Validation
Where app/Http/Controllers/AdminServiceDetailController.php:92
Issue / Evidence potential validation robustness
Suggested Fix consider adding stricter validation rules / sanitization for tier fields beyond string length
File Storage Error Handling
Where app/Http/Controllers/AdminServiceDetailController.php:166
Issue / Evidence file storage error handling
Suggested Fix add try-catch or validation to handle errors when moving uploaded files
Directory Permission
Where app/Http/Controllers/AdminServiceDetailController.php:160
Issue / Evidence directory permission
Suggested Fix verify or restrict directory permissions more strictly to improve security
Null Check
Where app/Http/Controllers/Api/RazorpayController.php:235
Issue / Evidence null check
Suggested Fix add explicit null checks when fetching ServiceDetail to prevent potential errors or leaks
Input Sanitation
Where app/Http/Controllers/AdminServiceDetailController.php:130
Issue / Evidence input sanitation
Suggested Fix trim/clean inputs earlier to reduce risk of inconsistent data states
Nullable Fields
Where database/migrations/2026_07_08_171851_add_call_type_tier_fields_to_service_details_table.php:13
Issue / Evidence nullable fields
Suggested Fix consider whether 'call_type' should be nullable if it's required in validation
Error Handling
Where resources/views/admin/service-detail-form.blade.php:47
Issue / Evidence error handling
Suggested Fix improve display or user feedback on SKU uniqueness errors to reduce confusion
Code Change Preview · .gitignore ?
Removed / Before Commit
- /Product Excel test only.xlsx
- /Avriti_Ratna_Updated.xlsx
- /Service Detail test.xlsx
- \ No newline at end of file
Added / After Commit
+ /Product Excel test only.xlsx
+ /Avriti_Ratna_Updated.xlsx
+ /Service Detail test.xlsx
+ /BACKEND_AI_PROMPT.md
+ \ No newline at end of file
Removed / Before Commit
- 
- public function store(Request $request): RedirectResponse
- {
-         $request->validate([
-             'name'              => ['required', 'string', 'max:255'],
-             'short_description' => ['nullable', 'string'],
-             'consultation_fee'  => ['nullable', 'string', 'max:100'],
-             'icon'              => ['nullable', 'string'],
-             'image'             => ['nullable', 'image', 'max:2048'],
-             'is_active'         => ['nullable', 'in:0,1'],
-         ]);
- 
-         $slug = Str::slug($request->name);
-         $originalSlug = $slug;
-         $count = 1;
-         while (ServiceDetail::where('slug', $slug)->exists()) {
-             $slug = $originalSlug . '-' . $count++;
-         }
Added / After Commit
+ 
+ public function store(Request $request): RedirectResponse
+ {
+         $this->validateServiceDetail($request);
+ 
+         $slug = $this->uniqueSlug($request->input('slug') ?: $request->name);
+ 
+ $imagePath = null;
+ if ($request->hasFile('image')) {
+             $imagePath = $this->storeImage($request->file('image'));
+ }
+ 
+ ServiceDetail::create([
+ 'name'              => $request->name,
+ 'slug'              => $slug,
+ 'short_description' => $request->short_description,
+             'call_type'         => $request->call_type,
+             'tier_fields'       => $this->parseTierFields($request),
Removed / Before Commit
- use App\Models\Coupon;
- use App\Models\Order;
- use App\Models\Product;
- use App\Services\CouponService;
- use App\Services\ShippingService;
- use App\Services\TaxService;
- $appliedCouponCode = $couponResult['coupon']->code;
- }
- 
- $taxResult      = TaxService::calculate($subtotal - $discount);
-         $shippingResult = ShippingService::calculate($subtotal - $discount, $shippingAddress['pincode'] ?? null);
-         $shippingCharge = $shippingResult['shipping_charge'];
- 
- $order = Order::create([
- 'order_number'          => $orderNumber,
- }
- 
- // 3. Order items create
Added / After Commit
+ use App\Models\Coupon;
+ use App\Models\Order;
+ use App\Models\Product;
+ use App\Models\ServiceDetail;
+ use App\Services\CouponService;
+ use App\Services\ShippingService;
+ use App\Services\TaxService;
+ $appliedCouponCode = $couponResult['coupon']->code;
+ }
+ 
+         $requestItems   = $request->input('items', []);
+         $allService     = count($requestItems) > 0 && collect($requestItems)->every(fn($i) => !empty($i['service_detail_id']));
+ $taxResult      = TaxService::calculate($subtotal - $discount);
+         $shippingCharge = $allService ? 0 : ShippingService::calculate($subtotal - $discount, $shippingAddress['pincode'] ?? null)['shipping_charge'];
+ 
+ $order = Order::create([
+ 'order_number'          => $orderNumber,
+ }
Removed / Before Commit
- {
- $details = ServiceDetail::where('is_active', true)
- ->orderBy('id')
-             ->get(['id', 'name', 'slug', 'short_description', 'icon', 'image', 'consultation_fee']);
- 
- $data = $details->map(function ($sd) {
- return [
- 'id'                => $sd->id,
- 'name'              => $sd->name,
- 'slug'              => $sd->slug,
- 'short_description' => $sd->short_description ?? '',
- 'icon'              => !empty($sd->icon) ? asset('services-svg/' . $sd->icon) : null,
- 'image'             => !empty($sd->image) ? asset($sd->image) : null,
-                 'consultation_fee'  => $sd->consultation_fee ?? '',
- ];
- })->values()->toArray();
- 
- 'name'              => $sd->name,
Added / After Commit
+ {
+ $details = ServiceDetail::where('is_active', true)
+ ->orderBy('id')
+             ->get(['id', 'name', 'slug', 'short_description', 'icon', 'image', 'call_type', 'tier_fields']);
+ 
+ $data = $details->map(function ($sd) {
+             $tiers = $this->formatTiers($sd->tier_fields);
+ return [
+ 'id'                => $sd->id,
+ 'name'              => $sd->name,
+ 'slug'              => $sd->slug,
+ 'short_description' => $sd->short_description ?? '',
+ 'icon'              => !empty($sd->icon) ? asset('services-svg/' . $sd->icon) : null,
+ 'image'             => !empty($sd->image) ? asset($sd->image) : null,
+                 'call_type'         => $sd->call_type ?? '',
+                 'tiers'             => $tiers,
+                 // backward compat: first tier's fee
+                 'consultation_fee'  => $tiers[0]['consultation_fee'] ?? '',
Removed / Before Commit
- 'name',
- 'slug',
- 'short_description',
-         'consultation_fee',
- 'icon',
- 'image',
- 'other_details',
- {
- return [
- 'other_details' => 'array',
- 'is_active'     => 'boolean',
- ];
- }
Added / After Commit
+ 'name',
+ 'slug',
+ 'short_description',
+         'call_type',
+         'tier_fields',
+ 'icon',
+ 'image',
+ 'other_details',
+ {
+ return [
+ 'other_details' => 'array',
+             'tier_fields'   => 'array',
+ 'is_active'     => 'boolean',
+ ];
+ }
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
+ {
+     public function up(): void
+     {
+         Schema::table('service_details', function (Blueprint $table) {
+             $table->string('call_type')->nullable()->after('image');
+             $table->json('tier_fields')->nullable()->after('call_type');
+         });
+ 
+         Schema::table('service_details', function (Blueprint $table) {
+             $table->dropColumn('consultation_fee');
+         });
Removed / Before Commit
- </tr>
- </thead>
- <tbody class="divide-y divide-gray-100 text-sm [&>tr:nth-child(even)]:bg-gray-100">
-         @forelse($banners as $banner)
- <tr class="hover:bg-blue-100 transition-colors">
- <td class="px-6 py-5 font-semibold text-gray-500">{{ $loop->iteration }}</td>
- <td class="px-6 py-5">
- </div>
- </td>
- </tr>
-         @empty
-         <tr>
-           <td colspan="5" class="px-6 py-12 text-center text-sm text-gray-400">No special offers added yet.</td>
-         </tr>
-         @endforelse
- </tbody>
- </table>
- </div>
Added / After Commit
+ </tr>
+ </thead>
+ <tbody class="divide-y divide-gray-100 text-sm [&>tr:nth-child(even)]:bg-gray-100">
+         @foreach($banners as $banner)
+ <tr class="hover:bg-blue-100 transition-colors">
+ <td class="px-6 py-5 font-semibold text-gray-500">{{ $loop->iteration }}</td>
+ <td class="px-6 py-5">
+ </div>
+ </td>
+ </tr>
+         @endforeach
+ </tbody>
+ </table>
+ </div>
Removed / Before Commit
- </div>
- @endif
- 
- @if ($errors->any())
- <div class="mb-6 rounded-2xl border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700">
-     <ul class="list-disc pl-4 space-y-1">
-       @foreach ($errors->all() as $error)<li>{{ $error }}</li>@endforeach
-     </ul>
- </div>
- @endif
- 
- <form method="POST" action="{{ $formAction }}" enctype="multipart/form-data">
- @csrf
- @if($isEdit) @method('PUT') @endif
- 
- <label class="mb-1.5 block text-sm font-medium text-gray-700">Name <span class="text-red-500">*</span></label>
- <input type="text" name="name" id="field-name"
- value="{{ old('name', $serviceDetail->name ?? '') }}"
Added / After Commit
+ </div>
+ @endif
+ 
+ {{-- SKU-uniqueness (cross-field) errors still surface here; per-field errors show inline --}}
+ @if ($errors->has('tiers'))
+ <div class="mb-6 rounded-2xl border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700">
+     {{ $errors->first('tiers') }}
+ </div>
+ @endif
+ 
+ <form id="service-detail-form" method="POST" action="{{ $formAction }}" enctype="multipart/form-data">
+ @csrf
+ @if($isEdit) @method('PUT') @endif
+ 
+ <label class="mb-1.5 block text-sm font-medium text-gray-700">Name <span class="text-red-500">*</span></label>
+ <input type="text" name="name" id="field-name"
+ value="{{ old('name', $serviceDetail->name ?? '') }}"
+           data-req="Name is required"
Removed / Before Commit
- <th class="px-6 py-4">No</th>
- <th class="px-6 py-4">Name</th>
- <th class="px-6 py-4">Slug</th>
-           <th class="px-6 py-4">Fee</th>
- <th class="px-6 py-4">Status</th>
- <th class="px-6 py-4">Action</th>
- </tr>
- </div>
- </td>
- <td class="px-6 py-5 text-gray-500">{{ $sd->slug }}</td>
-             <td class="px-6 py-5 text-gray-700 font-medium">{{ $sd->consultation_fee ?: '—' }}</td>
- <td class="px-6 py-5">
- @if($sd->is_active)
- <span class="inline-flex rounded-full bg-emerald-100 px-3 py-1 text-xs font-semibold text-emerald-700">Active</span>
Added / After Commit
+ <th class="px-6 py-4">No</th>
+ <th class="px-6 py-4">Name</th>
+ <th class="px-6 py-4">Slug</th>
+           <th class="px-6 py-4">Call Type</th>
+ <th class="px-6 py-4">Status</th>
+ <th class="px-6 py-4">Action</th>
+ </tr>
+ </div>
+ </td>
+ <td class="px-6 py-5 text-gray-500">{{ $sd->slug }}</td>
+             <td class="px-6 py-5">
+               @if($sd->call_type)
+                 <span class="inline-flex items-center gap-1.5 rounded-full bg-[#eef4ff] px-3 py-1 text-xs font-semibold text-[#1a41b1]">
+                   <i class="fa-solid {{ $sd->call_type === 'Zoom' ? 'fa-video' : 'fa-phone' }} text-[10px]"></i>
+                   {{ $sd->call_type }}
+                 </span>
+               @else
+                 <span class="text-gray-400">—</span>