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

Review Result ?

jattin01/avriti-backend · ecbc8c86
This commit integrates email notifications into the application, adding multiple mail classes and modifying controllers to send emails under various scenarios including contact forms, customer registration, password resets, and order placements. The implementation improves user experience and business communication. However, there are potential improvements around input validation, error handling, and security practices, such as protecting email data and confirming if mails are successfully sent.
Quality ?
85%
Security ?
70%
Business Value ?
90%
Maintainability ?
83%
Issues & Suggested Fixes ?
1AI detects the issue
2Shows file, line, or evidence
3Suggests the fix to apply
Missing Validation
Where app/Http/Controllers/Api/OrderController.php:40
Issue / Evidence missing explicit validation/fallback for billing email
Suggested Fix add more robust validation and fallback to improve bug risk and business value
No Error Handling After Sending Mail
Where app/Http/Controllers/Api/ContactController.php:30
Issue / Evidence no error handling after sending mail
Suggested Fix add try-catch blocks around Mail::send to handle failed emails to improve quality and bug risk
No Error Handling For Sending Reset Passwo...
Where app/Http/Controllers/Api/CustomerAuthController.php:110
Issue / Evidence no error handling for sending reset password mail
Suggested Fix add error handling to avoid silent failures and improve bug risk
No Handling For Failures When Sending Orde...
Where app/Http/Controllers/Api/OrderController.php:53
Issue / Evidence no handling for failures when sending order confirmation email
Suggested Fix add error handling for email sending
Too Brief And Contains A Typo
Where commit message
Issue / Evidence too brief and contains a typo
Suggested Fix use a descriptive commit message with correct spelling to improve quality and business value
Hardcoded Default Admin Email Environment...
Where config/mail.php:118
Issue / Evidence hardcoded default admin email environment variable reference
Suggested Fix ensure documentation and safe defaults for admin email to avoid misconfiguration
Sensitive Data Like Reset Tokens Sent With...
Where app/Mail/CustomerResetPasswordMail.php:14-16
Issue / Evidence sensitive data like reset tokens sent without mention of encryption or limited usage
Suggested Fix confirm secure handling of sensitive tokens in mail content to improve security
Code Change Preview · app/Http/Controllers/Api/ContactController.php ?
Removed / Before Commit
- namespace App\Http\Controllers\Api;
- 
- use App\Http\Controllers\Controller;
- use App\Models\Contact;
- use Illuminate\Http\Request;
- 
- class ContactController extends Controller
- {
- 'message' => 'required|string',
- ]);
- 
-         Contact::create([
- 'name'    => $request->name,
- 'email'   => $request->email,
- 'phone'   => $request->phone,
- 'message' => $request->message,
- ]);
- 
Added / After Commit
+ namespace App\Http\Controllers\Api;
+ 
+ use App\Http\Controllers\Controller;
+ use App\Mail\ContactAdminMail;
+ use App\Mail\ContactUserMail;
+ use App\Models\Contact;
+ use Illuminate\Http\Request;
+ use Illuminate\Support\Facades\Mail;
+ 
+ class ContactController extends Controller
+ {
+ 'message' => 'required|string',
+ ]);
+ 
+         $contact = Contact::create([
+ 'name'    => $request->name,
+ 'email'   => $request->email,
+ 'phone'   => $request->phone,
Removed / Before Commit
- namespace App\Http\Controllers\Api;
- 
- use App\Http\Controllers\Controller;
- use App\Models\Customer;
- use Illuminate\Http\JsonResponse;
- use Illuminate\Http\Request;
- use Illuminate\Support\Facades\DB;
- use Illuminate\Support\Facades\Hash;
- use Illuminate\Support\Str;
- use Illuminate\Validation\ValidationException;
- 
- 'password'  => $request->password,
- ]);
- 
- return response()->json([
- 'success' => true,
- 'message' => 'Registration successful.',
- ['token' => Hash::make($token), 'created_at' => now()]
Added / After Commit
+ namespace App\Http\Controllers\Api;
+ 
+ use App\Http\Controllers\Controller;
+ use App\Mail\CustomerRegistrationMail;
+ use App\Mail\CustomerResetPasswordMail;
+ use App\Mail\CustomerWelcomeMail;
+ use App\Models\Customer;
+ use Illuminate\Http\JsonResponse;
+ use Illuminate\Http\Request;
+ use Illuminate\Support\Facades\DB;
+ use Illuminate\Support\Facades\Hash;
+ use Illuminate\Support\Facades\Mail;
+ use Illuminate\Support\Str;
+ use Illuminate\Validation\ValidationException;
+ 
+ 'password'  => $request->password,
+ ]);
+ 
Removed / Before Commit
- namespace App\Http\Controllers\Api;
- 
- use App\Http\Controllers\Controller;
- use App\Models\Order;
- use App\Models\CartItem;
- use App\Models\Product;
- use Illuminate\Http\JsonResponse;
- use Illuminate\Http\Request;
- use Illuminate\Support\Str;
- 
- class OrderController extends Controller
- 'shipping_address.state'     => ['required', 'string'],
- 'shipping_address.pincode'   => ['required', 'string'],
- 'shipping_address.country'   => ['required', 'string'],
- 'payment_method'             => ['required', 'in:upi,card,cod'],
- 'subtotal'                   => ['required', 'numeric'],
- 'total'                      => ['required', 'numeric'],
- $customerId      = $request->user()->id;
Added / After Commit
+ namespace App\Http\Controllers\Api;
+ 
+ use App\Http\Controllers\Controller;
+ use App\Mail\OrderPlacedMail;
+ use App\Models\Order;
+ use App\Models\CartItem;
+ use App\Models\Product;
+ use Illuminate\Http\JsonResponse;
+ use Illuminate\Http\Request;
+ use Illuminate\Support\Facades\Mail;
+ use Illuminate\Support\Str;
+ 
+ class OrderController extends Controller
+ 'shipping_address.state'     => ['required', 'string'],
+ 'shipping_address.pincode'   => ['required', 'string'],
+ 'shipping_address.country'   => ['required', 'string'],
+             'billing_address'            => ['nullable', 'array'],
+             'billing_address.email'      => ['nullable', 'email'],
Removed / Before Commit

                                                
Added / After Commit
+ <?php
+ 
+ namespace App\Mail;
+ 
+ use App\Models\Contact;
+ use Illuminate\Bus\Queueable;
+ use Illuminate\Mail\Mailable;
+ use Illuminate\Queue\SerializesModels;
+ 
+ class ContactAdminMail extends Mailable
+ {
+     use Queueable, SerializesModels;
+ 
+     public function __construct(
+         public Contact $contact
+     ) {
+     }
+ 
Removed / Before Commit

                                                
Added / After Commit
+ <?php
+ 
+ namespace App\Mail;
+ 
+ use App\Models\Contact;
+ use Illuminate\Bus\Queueable;
+ use Illuminate\Mail\Mailable;
+ use Illuminate\Queue\SerializesModels;
+ 
+ class ContactUserMail extends Mailable
+ {
+     use Queueable, SerializesModels;
+ 
+     public function __construct(
+         public Contact $contact
+     ) {
+     }
+ 
Removed / Before Commit

                                                
Added / After Commit
+ <?php
+ 
+ namespace App\Mail;
+ 
+ use App\Models\Customer;
+ use Illuminate\Bus\Queueable;
+ use Illuminate\Mail\Mailable;
+ use Illuminate\Queue\SerializesModels;
+ 
+ class CustomerRegistrationMail extends Mailable
+ {
+     use Queueable, SerializesModels;
+ 
+     public function __construct(
+         public Customer $customer
+     ) {
+     }
+ 
Removed / Before Commit

                                                
Added / After Commit
+ <?php
+ 
+ namespace App\Mail;
+ 
+ use Illuminate\Bus\Queueable;
+ use Illuminate\Mail\Mailable;
+ use Illuminate\Queue\SerializesModels;
+ 
+ class CustomerResetPasswordMail extends Mailable
+ {
+     use Queueable, SerializesModels;
+ 
+     public function __construct(
+         public string $email,
+         public string $token,
+         public ?string $name = null
+     ) {
+     }
Removed / Before Commit

                                                
Added / After Commit
+ <?php
+ 
+ namespace App\Mail;
+ 
+ use App\Models\Customer;
+ use Illuminate\Bus\Queueable;
+ use Illuminate\Mail\Mailable;
+ use Illuminate\Queue\SerializesModels;
+ 
+ class CustomerWelcomeMail extends Mailable
+ {
+     use Queueable, SerializesModels;
+ 
+     public function __construct(
+         public Customer $customer
+     ) {
+     }
+ 
Removed / Before Commit

                                                
Added / After Commit
+ <?php
+ 
+ namespace App\Mail;
+ 
+ use Illuminate\Bus\Queueable;
+ use Illuminate\Mail\Mailable;
+ use Illuminate\Queue\SerializesModels;
+ 
+ class OrderPlacedMail extends Mailable
+ {
+     use Queueable, SerializesModels;
+ 
+     public function __construct(
+         public array $orderData
+     ) {
+     }
+ 
+     public function build(): self
Removed / Before Commit
- 'name' => env('MAIL_FROM_NAME', env('APP_NAME', 'Laravel')),
- ],
- 
- ];
Added / After Commit
+ 'name' => env('MAIL_FROM_NAME', env('APP_NAME', 'Laravel')),
+ ],
+ 
+     'admin_address' => env('ADMIN_MAIL'),
+ 
+ ];
Removed / Before Commit

                                                
Added / After Commit
+ <!DOCTYPE html>
+ <html lang="en">
+ <head>
+   <meta charset="UTF-8">
+   <meta name="viewport" content="width=device-width, initial-scale=1.0">
+   <title>New Contact Enquiry</title>
+   <link href="https://fonts.googleapis.com/css2?family=Basic&display=swap" rel="stylesheet">
+ </head>
+ <body style="margin:0;padding:0;background:linear-gradient(135deg,#b8d4f0 0%,#d4c5e8 50%,#c8dff0 100%);font-family:'Basic',Arial,sans-serif;color:#1a1a1a;">
+   <table cellpadding="0" cellspacing="0" border="0" style="max-width:560px;width:92%;margin:24px auto;background:#ffffff;border-radius:18px;overflow:hidden;box-shadow:0 6px 24px rgba(11,61,186,.12);">
+     <tr>
+       <td align="center" style="padding:30px 20px 22px;">
+         <img src="{{ url('img/logo1.png') }}" alt="Avriti" style="max-width:150px;width:100%;">
+       </td>
+     </tr>
+     <tr>
+       <td align="center" style="background:#0b3dba;padding:28px 28px;color:#ffffff;">
+         <div style="display:inline-block;width:44px;height:44px;border-radius:50%;border:2px solid #c5d3f0;line-height:44px;font-size:22px;margin-bottom:12px;">✉</div>
Removed / Before Commit

                                                
Added / After Commit
+ <!DOCTYPE html>
+ <html lang="en">
+ <head>
+   <meta charset="UTF-8">
+   <meta name="viewport" content="width=device-width, initial-scale=1.0">
+   <title>Thanks for Contacting Avriti</title>
+   <link href="https://fonts.googleapis.com/css2?family=Basic&display=swap" rel="stylesheet">
+ </head>
+ <body style="margin:0;padding:0;background:linear-gradient(135deg,#b8d4f0 0%,#d4c5e8 50%,#c8dff0 100%);font-family:'Basic',Arial,sans-serif;color:#1a1a1a;">
+   <table cellpadding="0" cellspacing="0" border="0" style="max-width:540px;width:92%;margin:24px auto;background:#ffffff;border-radius:18px;overflow:hidden;box-shadow:0 6px 24px rgba(11,61,186,.12);">
+     <tr>
+       <td align="center" style="padding:30px 20px 22px;">
+         <img src="{{ url('img/logo1.png') }}" alt="Avriti" style="max-width:150px;width:100%;">
+       </td>
+     </tr>
+     <tr>
+       <td align="center" style="background:#0b3dba;padding:30px 28px;color:#ffffff;">
+         <div style="display:inline-block;width:46px;height:46px;border-radius:50%;border:2px solid #22c55e;line-height:46px;font-size:24px;color:#22c55e;margin-bottom:12px;">✓</div>
Removed / Before Commit

                                                
Added / After Commit
+ <!DOCTYPE html>
+ <html lang="en">
+ <head>
+   <meta charset="UTF-8" />
+   <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
+   <title>Registration</title>
+   <link href="https://fonts.googleapis.com/css2?family=Basic&display=swap" rel="stylesheet">
+ </head>
+ <body style="margin:0; padding:0; background:#f0f4f8; font-family: 'Basic', Arial, sans-serif;">
+   <table cellpadding="0" cellspacing="0" border="0" style="max-width:500px; width:90%; margin:20px auto;background-color:#ffffff; border-radius:12px; overflow:hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.08);">
+     <tr>
+       <td align="center" style="padding: 30px 20px 20px 20px;">
+         <img src="{{ url('img/logo1.png') }}" alt="Avriti" style="max-width:150px; width:100%;">
+       </td>
+     </tr>
+     <tr>
+       <td style="padding: 0 20px 10px 20px; font-size:16px; color:#1a1a1a; font-weight:600;">
+         Hello <b style="color:#0b3dba;">{{ $customer->full_name }}</b>
Removed / Before Commit

                                                
Added / After Commit
+ <!DOCTYPE html>
+ <html lang="en">
+ <head>
+   <meta charset="UTF-8" />
+   <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
+   <link href="https://fonts.googleapis.com/css2?family=Basic&display=swap" rel="stylesheet">
+   <title>Reset Password</title>
+ </head>
+ <body style="margin:0; padding:0; font-family: 'Basic', Arial, sans-serif; background:#f0f4f8;">
+   @php($resetUrl = rtrim(config('app.url'), '/') . '/reset-password?email=' . urlencode($email) . '&token=' . urlencode($token))
+   <table width="420" cellpadding="0" cellspacing="0" border="0" style="max-width:500px; width:90%; margin:20px auto;background-color:#ffffff; border-radius:16px; overflow:hidden; box-shadow:0 4px 20px rgba(0,0,0,0.08);">
+     <tr><td align="center" style="padding: 30px 20px 0 20px;"><img src="{{ url('img/logo1.png') }}" alt="Avriti" style="max-width:150px; width:100%;"></td></tr>
+     <tr>
+       <td align="center" style="padding:40px 40px 30px 40px;">
+         <div style="font-size:64px; line-height:1; margin-bottom:6px;">📧🔒</div>
+         <div style="font-size:22px; font-weight:700; color:#1a1a1a; margin-top:20px;">Reset password</div>
+         <div style="font-size:14px; color:#0b3dba; font-weight:600; margin-top:16px;">Hey {{ $name ?: 'Customer' }},</div>
+         <div style="font-size:13px; color:#555555; margin-top:10px; line-height:1.7; text-align:center; max-width:300px; margin-left:auto; margin-right:auto;">You're receiving this e-mail because you requested a password reset for your account.</div>
Removed / Before Commit

                                                
Added / After Commit
+ <!DOCTYPE html>
+ <html lang="en">
+ <head>
+   <meta charset="UTF-8" />
+   <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
+   <title>Welcome to Avriti</title>
+   <link href="https://fonts.googleapis.com/css2?family=Basic&display=swap" rel="stylesheet">
+ </head>
+ <body style="margin:0; padding:0; background:#f0f4f8; font-family: 'Basic', Arial, sans-serif;">
+   <table cellpadding="0" cellspacing="0" border="0" style="max-width:500px; width:90%; margin:20px auto;background-color:#ffffff; border-radius:12px; overflow:hidden; box-shadow:0 2px 10px rgba(0,0,0,0.07);">
+     <tr><td align="center" style="padding: 30px 20px 20px 20px;"><img src="{{ url('img/logo1.png') }}" alt="Avriti" style="max-width:150px; width:100%;"></td></tr>
+     <tr>
+       <td style="padding:0 40px 24px 40px;">
+         <table width="100%" cellpadding="0" cellspacing="0" border="0" style="background-color:#0b3dba; border-radius:12px;">
+           <tr><td align="center" style="padding: 20px;"><img src="{{ url('img/welcome.png') }}" alt="Welcome" style="max-width:100%;border-radius:12px;"></td></tr>
+         </table>
+       </td>
+     </tr>
Removed / Before Commit

                                                
Added / After Commit
+ @php
+   $items = $orderData['items'] ?? [];
+   $billing = $orderData['billing_address'] ?? [];
+   $shipping_addr = $orderData['shipping_address'] ?? [];
+   $itemsCount = count($items);
+   $subtotal = (float) ($orderData['subtotal'] ?? 0);
+   $tax = (float) ($orderData['tax'] ?? 0);
+   $shippingCost = (float) ($orderData['shipping'] ?? 0);
+   $total = (float) ($orderData['total'] ?? 0);
+   $fallbackImage = url('img/logo1.png');
+ @endphp
+ <!DOCTYPE html>
+ <html lang="en">
+ <head>
+   <meta charset="UTF-8"/>
+   <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
+   <title>Order Confirmation</title>
+   <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
Removed / Before Commit
- <?php
- 
- use Illuminate\Support\Facades\Mail;
- use App\Http\Controllers\AuthController;
- use App\Http\Controllers\AdminProductCategoryController;
- use App\Http\Controllers\AdminProductController;
- });
- 
- // 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 {
- Route::get('/login', [AuthController::class, 'showLogin'])->name('login');
Added / After Commit
+ <?php
+ 
+ // use Illuminate\Support\Facades\Mail;
+ use App\Http\Controllers\AuthController;
+ use App\Http\Controllers\AdminProductCategoryController;
+ use App\Http\Controllers\AdminProductController;
+ });
+ 
+ // 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 {
+ Route::get('/login', [AuthController::class, 'showLogin'])->name('login');