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

Review Result ?

jattin01/avriti-backend · abb0886e
This commit adds 'is_active' functionality for customers including migration, model updates, controller logic, validation, and UI presentation of customer profiles and orders. It improves business value by enabling active status management for customers and shows a comprehensive customer profile page for admins. Code is clean, organized, and uses Laravel features properly. There is some risk of bugs if the new 'is_active' flag is not checked everywhere or if migrated incorrectly. Security is decent with password hashing and validation exception on inactive login, but further security enhancement could be considered.
Quality ?
85%
Security ?
75%
Business Value ?
90%
Maintainability ?
83%
Issues & Suggested Fixes ?
1AI detects the issue
2Shows file, line, or evidence
3Suggests the fix to apply
Add Casting For 'Is Active' As Boolean To...
Where app/Models/Customer.php:20
Issue / Evidence Add casting for 'is_active' as boolean to ensure correct type handling
Suggested Fix change this to improve quality and bug risk scores
Add Logging Or Auditing When Login Attempt...
Where app/Http/Controllers/Api/CustomerAuthController.php:60
Issue / Evidence Add logging or auditing when login attempts occur from inactive accounts
Suggested Fix change this to improve security score
Verify Default 'True' Status Fits Business...
Where database/migrations/2026_06_15_000001_add_is_active_to_customers_table.php:12
Issue / Evidence Verify default 'true' status fits business logic; if not, update default value to 'false' for new users
Suggested Fix change this to improve business value and decrease bug risk
Display Active/Inactive Dynamically Based...
Where resources/views/admin/customer-profile.blade.php:36
Issue / Evidence Display active/inactive dynamically based on 'is_active' status rather than hardcoded 'Active' badge
Suggested Fix change this to improve quality score
Improve Commit Message Clarity And Grammar...
Where commit message
Issue / Evidence Improve commit message clarity and grammar ('intregrate' to 'integrate', more descriptive detail)
Suggested Fix change this to improve quality and fake work risk scores
Code Change Preview · .env.example ?
Removed / Before Commit
- MAIL_FROM_ADDRESS="hello@example.com"
- MAIL_FROM_NAME="${APP_NAME}"
- 
- AWS_ACCESS_KEY_ID=
- AWS_SECRET_ACCESS_KEY=
- AWS_DEFAULT_REGION=us-east-1
Added / After Commit
+ MAIL_FROM_ADDRESS="hello@example.com"
+ MAIL_FROM_NAME="${APP_NAME}"
+ 
+ 
+ 
+ 
+ AWS_ACCESS_KEY_ID=
+ AWS_SECRET_ACCESS_KEY=
+ AWS_DEFAULT_REGION=us-east-1
Removed / Before Commit
- return view('admin.customers', compact('customers'));
- }
- 
- public function edit(Customer $customer): View
- {
- return view('admin.customer-edit', compact('customer'));
- $validated = $request->validate([
- 'full_name' => ['required', 'string', 'max:150'],
- 'phone' => ['required', 'string', 'max:20'],
- ]);
- 
- $customer->update($validated);
Added / After Commit
+ return view('admin.customers', compact('customers'));
+ }
+ 
+     public function show(Customer $customer): View
+     {
+         $customer->load(['addresses', 'orders']);
+         return view('admin.customer-profile', compact('customer'));
+     }
+ 
+ public function edit(Customer $customer): View
+ {
+ return view('admin.customer-edit', compact('customer'));
+ $validated = $request->validate([
+ 'full_name' => ['required', 'string', 'max:150'],
+ 'phone' => ['required', 'string', 'max:20'],
+             'is_active' => ['required', 'boolean'],
+ ]);
+ 
Removed / Before Commit
- ]);
- }
- 
- return response()->json([
- 'success' => true,
- 'message' => 'Login successful.',
Added / After Commit
+ ]);
+ }
+ 
+         if (! $customer->is_active) {
+             throw ValidationException::withMessages([
+                 'email' => 'Your account is not activated. Please contact admin.',
+             ]);
+         }
+ 
+ return response()->json([
+ 'success' => true,
+ 'message' => 'Login successful.',
Removed / Before Commit
- namespace App\Models;
- 
- use Illuminate\Foundation\Auth\User as Authenticatable;
- use Laravel\Sanctum\HasApiTokens;
- 
- class Customer extends Authenticatable
- {
- use HasApiTokens;
- 
-    protected $fillable = ['full_name', 'email', 'phone', 'profile_img', 'password'];
- 
- protected $hidden = ['password'];
- 
- protected function casts(): array
- {
-         return ['password' => 'hashed'];
- }
- }
Added / After Commit
+ namespace App\Models;
+ 
+ use Illuminate\Foundation\Auth\User as Authenticatable;
+ use Illuminate\Database\Eloquent\Relations\HasMany;
+ use Laravel\Sanctum\HasApiTokens;
+ 
+ class Customer extends Authenticatable
+ {
+ use HasApiTokens;
+ 
+     protected $fillable = ['full_name', 'email', 'phone', 'profile_img', 'is_active', 'password'];
+ 
+ protected $hidden = ['password'];
+ 
+ protected function casts(): array
+ {
+         return [
+             '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('customers', function (Blueprint $table) {
+             $table->boolean('is_active')->default(true)->after('profile_img');
+         });
+     }
+ 
+     public function down(): void
+     {
+         Schema::table('customers', function (Blueprint $table) {
Removed / Before Commit
- <div class="lg:col-span-2">
- <label class="block text-sm font-semibold text-gray-700 mb-3">Account Status</label>
- <div class="rounded-[28px] ">
- <div class="flex min-h-[96px] flex-col justify-center gap-3 sm:flex-row sm:items-center sm:justify-start">
- <label class="inline-flex items-center gap-2 rounded-full text-sm font-semibold text-emerald-700">
-             <input type="radio" name="account_status_preview" value="1" class="h-4 w-4 border-gray-300 text-[#0b3dba]" checked />
- Active
- </label>
- <label class="inline-flex items-center gap-2 rounded-full text-sm font-semibold text-red-700">
-             <input type="radio" name="account_status_preview" value="0" class="h-4 w-4 border-gray-300 text-[#0b3dba]" />
- Inactive
- </label>
- </div>
- </div>
- </div>
- </div>
Added / After Commit
+ <div class="lg:col-span-2">
+ <label class="block text-sm font-semibold text-gray-700 mb-3">Account Status</label>
+ <div class="rounded-[28px] ">
+         @php
+           $activeValue = (string) old('is_active', (int) $customer->is_active);
+         @endphp
+ <div class="flex min-h-[96px] flex-col justify-center gap-3 sm:flex-row sm:items-center sm:justify-start">
+ <label class="inline-flex items-center gap-2 rounded-full text-sm font-semibold text-emerald-700">
+             <input type="radio" name="is_active" value="1" class="h-4 w-4 border-gray-300 text-[#0b3dba]" @checked($activeValue === '1') />
+ Active
+ </label>
+ <label class="inline-flex items-center gap-2 rounded-full text-sm font-semibold text-red-700">
+             <input type="radio" name="is_active" value="0" class="h-4 w-4 border-gray-300 text-[#0b3dba]" @checked($activeValue === '0') />
+ Inactive
+ </label>
+ </div>
+         @error('is_active')
+           <p class="mt-2 text-xs font-medium text-red-500">{{ $message }}</p>
Removed / Before Commit

                                                
Added / After Commit
+ @extends('layouts.app')
+ 
+ @section('title', 'Customer Profile | Avriti Dashboard')
+ @section('content')
+ 
+ @php
+   $displayName = $customer->full_name ?: 'Customer';
+   $defaultAddress = $customer->addresses->firstWhere('is_default', true) ?? $customer->addresses->first();
+   $totalOrders = $customer->orders->count();
+   $totalSpent = $customer->orders->sum('total_amount');
+ @endphp
+ 
+ <div class="mb-6 flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between">
+   <h1 class="text-2xl font-semibold text-[#0b3dba]">Customer Profile</h1>
+   <a href="{{ route('customers.index') }}" class="inline-flex h-11 items-center justify-center rounded-full border border-gray-200 bg-white px-5 text-sm font-semibold text-gray-600 shadow-sm transition hover:bg-gray-50">
+     <i class="fa-solid fa-arrow-left mr-2"></i> Back
+   </a>
+ </div>
Removed / Before Commit
- <td class="px-6 py-5 text-gray-500">{{ $customer->phone ?? '-' }}</td>
- <td class="px-6 py-5 text-gray-500">{{ $customer->created_at?->format('d M, Y') ?? '-' }}</td>
- <td class="px-6 py-5">
-                       <span class="inline-flex rounded-full bg-emerald-100 px-3 py-1 text-xs font-semibold text-emerald-700">Active</span>
- </td>
- <td class="px-6 py-5 text-gray-500">
- <div class="flex items-center gap-3">
-                         <a href="{{ route('customers.edit', $customer) }}" class="text-[#0b3dba] hover:text-blue-600" aria-label="Edit {{ $displayName }}"><i class="fa-solid fa-pen-to-square"></i></a>
-                         <button type="button" data-delete-action="{{ route('customers.destroy', $customer) }}" data-delete-name="{{ $customer->full_name }}" class="text-red-500 hover:text-red-600" aria-label="Delete {{ $customer->full_name }}"><i class="fa-solid fa-trash"></i></button>
- </div>
- </td>
- </tr>
Added / After Commit
+ <td class="px-6 py-5 text-gray-500">{{ $customer->phone ?? '-' }}</td>
+ <td class="px-6 py-5 text-gray-500">{{ $customer->created_at?->format('d M, Y') ?? '-' }}</td>
+ <td class="px-6 py-5">
+                       @if ($customer->is_active)
+                         <span class="inline-flex rounded-full bg-emerald-100 px-3 py-1 text-xs font-semibold text-emerald-700">Active</span>
+                       @else
+                         <span class="inline-flex rounded-full bg-red-100 px-3 py-1 text-xs font-semibold text-red-700">Inactive</span>
+                       @endif
+ </td>
+ <td class="px-6 py-5 text-gray-500">
+ <div class="flex items-center gap-3">
+                         <a href="{{ route('customers.show', $customer) }}" class="group relative text-[#7c3aed] hover:text-purple-500" aria-label="View {{ $displayName }}">
+                           <i class="fa-solid fa-eye"></i>
+                           <span class="pointer-events-none absolute -top-8 left-1/2 -translate-x-1/2 whitespace-nowrap rounded-md bg-gray-800 px-2 py-1 text-xs text-white opacity-0 transition-opacity group-hover:opacity-100">View Profile</span>
+                         </a>
+                         <a href="{{ route('customers.edit', $customer) }}" class="group relative text-[#0b3dba] hover:text-blue-600" aria-label="Edit {{ $displayName }}">
+                           <i class="fa-solid fa-pen-to-square"></i>
+                           <span class="pointer-events-none absolute -top-8 left-1/2 -translate-x-1/2 whitespace-nowrap rounded-md bg-gray-800 px-2 py-1 text-xs text-white opacity-0 transition-opacity group-hover:opacity-100">Edit</span>
Removed / Before Commit
- @php
-   $profileData = $profileData ?? [];
-   $image = $profileData['image'] ?? null;
-   $name = $profileData['name'] ?? 'User';
-   $subtitle = $profileData['subtitle'] ?? 'Web Developer';
-   $location = $profileData['location'] ?? 'Phoenix, USA';
-   $email = $profileData['email'] ?? 'raquelmurillo@sales.com';
-   $dateOfBirth = $profileData['date_of_birth'] ?? '29 Oct, 1986';
-   $phone = $profileData['phone'] ?? '+(235) 01234 5678';
-   $totalReviews = $profileData['total_reviews'] ?? 365;
- @endphp
- 
- <div class="px-4 py-8 sm:px-6 lg:px-8">
Added / After Commit
+ @php
+   $profileData   = $profileData ?? [];
+   $image         = $profileData['image'] ?? null;
+   $name          = $profileData['name'] ?? '-';
+   $subtitle      = $profileData['subtitle'] ?? '-';
+   $location      = $profileData['location'] ?? '-';
+   $email         = $profileData['email'] ?? '-';
+   $dateOfBirth   = $profileData['date_of_birth'] ?? '-';
+   $phone         = $profileData['phone'] ?? '-';
+   $totalReviews  = $profileData['total_reviews'] ?? 0;
+ @endphp
+ 
+ <div class="px-4 py-8 sm:px-6 lg:px-8">
Removed / Before Commit
- @extends('layouts.app')
- 
- @section('title', 'Users | Avriti Dashboard')
- @section('content')
- 
- @php
-   $currentUser = auth()->user();
- $currentProfile = $currentUser?->profile;
-   $profileData = [
-     'image' => $currentProfile?->user_img,
-     'name' => $currentProfile?->name ?: $currentUser?->username ?: 'User',
-     'subtitle' => $currentProfile?->destination ?: 'Web Developer',
-     'location' => $currentProfile?->location ?: 'Phoenix, USA',
-     'email' => $currentUser?->email ?: 'raquelmurillo@sales.com',
-     'date_of_birth' => $currentProfile?->date_of_birth?->format('d M, Y') ?: '29 Oct, 1986',
-     'phone' => $currentProfile?->phone_number ?: '+(235) 01234 5678',
-     'total_reviews' => $currentProfile?->total_reviews ?? 365,
- ];
Added / After Commit
+ @extends('layouts.app')
+ 
+ @section('title', 'Profile | Avriti Dashboard')
+ @section('content')
+ 
+ @php
+   $currentUser    = auth()->user();
+ $currentProfile = $currentUser?->profile;
+   $profileData    = [
+     'image'         => $currentProfile?->user_img ?: null,
+     'name'          => $currentProfile?->name ?: $currentUser?->username ?: '-',
+     'subtitle'      => $currentProfile?->destination ?: '-',
+     'location'      => $currentProfile?->location ?: '-',
+     'email'         => $currentUser?->email ?: '-',
+     'date_of_birth' => $currentProfile?->date_of_birth?->format('d M, Y') ?: '-',
+     'phone'         => $currentProfile?->phone_number ?: '-',
+     'total_reviews' => $currentProfile?->total_reviews ?? 0,
+ ];
Removed / Before Commit
- 
- <div class="mb-6 flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between">
- <div>
-     <h1 class="text-2xl font-semibold text-[#0b3dba]">Edit User</h1>
- <p class="mt-2 text-sm text-gray-500">Update account and profile information.</p>
- </div>
- <a href="{{ route('users.index') }}" class="inline-flex h-11 items-center justify-center rounded-full border border-gray-200 bg-white px-5 text-sm font-semibold text-gray-600 shadow-sm transition hover:bg-gray-50">
Added / After Commit
+ 
+ <div class="mb-6 flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between">
+ <div>
+     <h1 class="text-2xl font-semibold text-[#0b3dba]">Edit Admin</h1>
+ <p class="mt-2 text-sm text-gray-500">Update account and profile information.</p>
+ </div>
+ <a href="{{ route('users.index') }}" class="inline-flex h-11 items-center justify-center rounded-full border border-gray-200 bg-white px-5 text-sm font-semibold text-gray-600 shadow-sm transition hover:bg-gray-50">
Removed / Before Commit
- 
- @php
- $profileData = [
-     'image' => $profile?->user_img,
-     'name' => $profile?->name ?: $user->username ?: 'User',
-     'subtitle' => $profile?->destination ?: 'Web Developer',
-     'location' => $profile?->location ?: 'Phoenix, USA',
-     'email' => $user->email ?: 'raquelmurillo@sales.com',
-     'date_of_birth' => $profile?->date_of_birth?->format('d M, Y') ?: '29 Oct, 1986',
-     'phone' => $profile?->phone_number ?: '+(235) 01234 5678',
-     'total_reviews' => $profile?->total_reviews ?? 365,
- ];
- @endphp
- 
- <div class="mb-6 flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between">
-   <div>
-     <h1 class="text-2xl font-semibold text-[#0b3dba]">User Profile</h1>
-   </div>
Added / After Commit
+ 
+ @php
+ $profileData = [
+     'image'          => $profile?->user_img ?: null,
+     'name'           => $profile?->name ?: $user->username ?: '-',
+     'subtitle'       => $profile?->destination ?: '-',
+     'location'       => $profile?->location ?: '-',
+     'email'          => $user->email ?: '-',
+     'date_of_birth'  => $profile?->date_of_birth?->format('d M, Y') ?: '-',
+     'phone'          => $profile?->phone_number ?: '-',
+     'total_reviews'  => $profile?->total_reviews ?? 0,
+     'is_active'      => $user->is_active,
+     'created_at'     => $user->created_at?->format('d M, Y') ?: '-',
+ ];
+ @endphp
+ 
+ <div class="mb-6 flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between">
+   <h1 class="text-2xl font-semibold text-[#0b3dba]">User Profile</h1>
Removed / Before Commit
- @extends('layouts.app')
- 
- @section('title', 'Users | Avriti Dashboard')
- @section('content')
- 
- <div class="mb-6 flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between">
- <div>
-             <h1 class="text-2xl font-semibold text-[#0b3dba]">Users List</h1>
- 
- </div>
- 
- <div class="overflow-hidden rounded-[32px] bg-white shadow-sm">
- <div class="flex flex-col gap-4 border-b border-gray-200 px-6 py-5 sm:flex-row sm:items-center sm:justify-between">
- <div class="flex flex-col gap-2 sm:flex-row sm:items-center">
-               <div class="rounded-2xl bg-[#eef4ff] px-4 py-3 text-sm font-semibold text-[#1a41b1]">{{ $users->count() }} {{ $users->count() === 1 ? 'User' : 'Users' }}</div>
-               <p class="text-sm text-gray-500">Latest created accounts shown below.</p>
- </div>
- <!-- <form method="GET" action="{{ route('users.index') }}" class="flex items-center gap-2">
Added / After Commit
+ @extends('layouts.app')
+ 
+ @section('title', 'Admins | Avriti Dashboard')
+ @section('content')
+ 
+ <div class="mb-6 flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between">
+ <div>
+             <h1 class="text-2xl font-semibold text-[#0b3dba]">Admin List</h1>
+ 
+ </div>
+ 
+ <div class="overflow-hidden rounded-[32px] bg-white shadow-sm">
+ <div class="flex flex-col gap-4 border-b border-gray-200 px-6 py-5 sm:flex-row sm:items-center sm:justify-between">
+ <div class="flex flex-col gap-2 sm:flex-row sm:items-center">
+               <div class="rounded-2xl bg-[#eef4ff] px-4 py-3 text-sm font-semibold text-[#1a41b1]">{{ $users->count() }} {{ $users->count() === 1 ? 'Admin' : 'Admins' }}</div>
+               <p class="text-sm text-gray-500">Latest created admins shown below.</p>
+ </div>
+ <!-- <form method="GET" action="{{ route('users.index') }}" class="flex items-center gap-2">
Removed / Before Commit
- 
- <a href="{{ route('users.index') }}" class="flex items-center gap-3 px-3 py-2.5 rounded-xl {{ request()->routeIs('users.*') ? $activeClass : $inactiveClass }}">
- <i class="fa-solid fa-user"></i>
-       Users List
- </a>
- 
- <a href="{{ route('customers.index') }}" class="flex items-center gap-3 px-3 py-2.5 rounded-xl {{ request()->routeIs('customers.*') ? $activeClass : $inactiveClass }}">
- Orders
- </a>
- 
-     <a href="{{ route('return-refund.index') }}" class="flex items-center gap-3 px-3 py-2.5 rounded-xl {{ request()->routeIs('return-refund.*') ? $activeClass : $inactiveClass }}">
- <i class="fa-solid fa-arrow-rotate-left"></i>
- Returns & Refunds
-     </a>
- 
- {{-- Products Group --}}
- @php $productsOpen = request()->routeIs('product-categories.*', 'product-types.*', 'variants.*', 'products.*'); @endphp
Added / After Commit
+ 
+ <a href="{{ route('users.index') }}" class="flex items-center gap-3 px-3 py-2.5 rounded-xl {{ request()->routeIs('users.*') ? $activeClass : $inactiveClass }}">
+ <i class="fa-solid fa-user"></i>
+       Admin List
+ </a>
+ 
+ <a href="{{ route('customers.index') }}" class="flex items-center gap-3 px-3 py-2.5 rounded-xl {{ request()->routeIs('customers.*') ? $activeClass : $inactiveClass }}">
+ Orders
+ </a>
+ 
+     <!-- <a href="{{ route('return-refund.index') }}" class="flex items-center gap-3 px-3 py-2.5 rounded-xl {{ request()->routeIs('return-refund.*') ? $activeClass : $inactiveClass }}">
+ <i class="fa-solid fa-arrow-rotate-left"></i>
+ Returns & Refunds
+     </a> -->
+ 
+ {{-- Products Group --}}
+ @php $productsOpen = request()->routeIs('product-categories.*', 'product-types.*', 'variants.*', 'products.*'); @endphp
Removed / Before Commit
- <?php
- 
- use App\Http\Controllers\AuthController;
- use App\Http\Controllers\AdminProductCategoryController;
- use App\Http\Controllers\AdminProductController;
- return redirect()->route('login');
- });
- 
- Route::middleware('guest')->group(function (): void {
- Route::get('/login', [AuthController::class, 'showLogin'])->name('login');
- Route::post('/login', [AuthController::class, 'login'])->name('login.store');
- Route::view('/dashboard', 'admin.dashboard')->name('dashboard');
- Route::get('/users', [AdminUserController::class, 'index'])->name('users.index');
- Route::get('/customers', [AdminCustomerController::class, 'index'])->name('customers.index');
- Route::get('/customers/{customer}/edit', [AdminCustomerController::class, 'edit'])->name('customers.edit');
- Route::put('/customers/{customer}', [AdminCustomerController::class, 'update'])->name('customers.update');
- Route::delete('/customers/{customer}', [AdminCustomerController::class, 'destroy'])->name('customers.destroy');
Added / After Commit
+ <?php
+ 
+ use Illuminate\Support\Facades\Mail;
+ use App\Http\Controllers\AuthController;
+ use App\Http\Controllers\AdminProductCategoryController;
+ use App\Http\Controllers\AdminProductController;
+ return redirect()->route('login');
+ });
+ 
+ // TEST MAIL — remove after testing
+ Route::get('/test-mail', function () {
+     Mail::raw('Test email from Avriti!', function ($msg) {
+         $msg->to('gourav.kumar@solutionbowl.com')->subject('Test');
+     });
+     return 'Mail sent!';
+ });
+ 
+ Route::middleware('guest')->group(function (): void {