Posts

Showing posts from March, 2025

Assign a delivery to the nearest available driver

 Great — you already have clean Mongoose models! To assign a delivery to the nearest available driver , you'll implement a geo-based query on the Driver collection to find a driver close to the restaurant’s location and available. ✅ Step-by-Step Logic 1. Get the Restaurant Location From the Restaurant model: js Copy Edit const restaurant = await Restaurant . findById (restaurantId); const { lat, lng } = restaurant. address . coordinates ; 2. Find the Nearest Available Driver You can use MongoDB's geoNear feature if you convert currentLocation into a 2dsphere index : 🛠 Modify Driver model: js Copy Edit driverSchema. index ({ currentLocation : "2dsphere" }); ✅ This lets MongoDB understand lat/lng for spatial queries. 3. Query for Nearby Available Drivers js Copy Edit const nearbyDrivers = await Driver . find ({ status : 'available' , currentLocation : { $near : { $geometry : { type : "Point" , co...

How to Save Notifications in the Database in Laravel

  How to Save Notifications in the Database in Laravel Laravel provides a built-in way to store notifications in the database using the database channel. Here’s how you can set it up. 1. Create the Notifications Table Laravel comes with a built-in migration for notifications. If you haven’t migrated it yet, run: php artisan notifications:table php artisan migrate This will create a notifications table in your database with fields like: id (unique identifier) type (notification class) notifiable_id & notifiable_type (user or model that received the notification) data (JSON field storing notification details) read_at (timestamp for when the notification is read) 2. Update Your Notification Class Modify your CommentAddedNotification to use the database channel and store data. Example: app/Notifications/CommentAddedNotification.php namespace App \ Notifications ; use Illuminate \ Bus \ Queueable ; use Illuminate \ Contracts \ Queue \ ShouldQueue ; us...

Modern Color Combination - e Commerce app

Image
https://chatgpt.com/g/g-p-67bae3de4208819182518a6cffbed683-hk/c/67d25926-deac-8012-98b1-67fe5b9e70ce Check this The colors you've selected offer a great mix of warm and cool tones with a modern, bold, and elegant aesthetic . Here's how you can best use them in your UI design: Recommended UI Usage of Your Selected Colors Primary Color (#09b7b5 - Teal) Ideal for buttons, highlights, and active states . Can be used as an accent color in graphs, icons, and interactive elements. Secondary Color (#ad4b40 - Warm Brick Red) Great for warnings, call-to-action (CTA) buttons, or section dividers . Use it sparingly to avoid visual overload . Background Color (#153544 - Dark Blue-Gray) Perfect for dark mode UI or backgrounds to create contrast. Provides a sleek, professional look when paired with lighter text. Text and Deep Accent (#01040b - Almost Black) Best for text elements, headers, and deep accents . Ensures high readability on both light and dark bac...