Task Reminder with Laravel & MongoDB
June 30, 2025📌 Building a Task Reminder App
This guide shows how to set up a Laravel app using MongoDB to implement a task reminder system with authentication, CRUD, and scheduled email reminders.
Prerequisites
- MongoDB Atlas cluster
- PHP + MongoDB extension
- Composer, NPM
- Basic Laravel & MongoDB knowledge
1. Start Laravel Project & Add MongoDB
composer create‑project laravel/laravel task‑reminder
cd task‑reminder
composer require mongodb/laravel-mongodb
Then in config/database.php, add:
'connections' => [
'mongodb' => [
'driver' => 'mongodb',
'dsn' => env('MONGODB_URI'),
'database' => 'YOUR_DB',
],
],
2. Authentication with Breeze
composer require laravel/breeze --dev
php artisan breeze:install
php artisan migrate
npm install && npm run dev
php artisan serve
3. Add Ping Route to Test MongoDB
Route::get('/ping', function() {
try {
DB::connection('mongodb')->command(['ping'=>1]);
return ['msg' => 'MongoDB is accessible!'];
} catch (Exception $e) {
return ['msg' => 'Not connected: '.$e->getMessage()];
}
});
4. Task Model & Controller (CRUD)
php artisan make:model Task --resource --controller
// in Task.php
use MongoDB\Laravel\Eloquent\Model;
class Task extends Model {
protected $connection='mongodb';
protected $fillable=['title','description','due_date','email','reminder_time','last_notification_date'];
}
Controller handles index, create, store, edit, update, destroy. Format dates with Carbon, link tasks to auth()->user()->email.
5. Views with Bootstrap
- Create form input: title, description, due_date, reminder_time
- Edit form similar
- Index page lists tasks, with Edit/Delete buttons
6. Send Reminder Emails
php artisan make:command SendTaskReminders
// handle() in SendTaskReminders.php
$now = Carbon::now();
$tasks = Task::whereNull('last_notification_date')
->where('reminder_time','>=',$now->subMinutes(10))
->get();
foreach($tasks as $task){
Mail::raw("Reminder: {$task->title}", function($msg) use($task){
$msg->to($task->email)
->subject("Task Reminder: {$task->title}");
});
$task->last_notification_date = $now;
$task->save();
}
7. Schedule the Command
// in console.php
Schedule::command('app:send-task-reminders')->everyMinute();
// add cron: * * * * * php /path/artisan schedule:run
Conclusion
You’ve built a full task reminder system with MongoDB storage, user auth, CRUD, and scheduled email notifications using Laravel.
Blog
Stop Copy-Pasting Code! Learn How to Use Traits in Laravel the Right Way
Jul 01, 2025
🚫 Stop Copy-Pasting Code! Ever duplicated slug logic or logging across multiple models? Laravel's Traits got your back. 1. What’s a Trait?...
Using useCallback in React: Benefits, Limitations, Best Practices
Jul 31, 2025
The useCallback hook in React is used to return a memoized version of a callback function, so it's only recreated when its dependencies change. The...
Mastering Laravel 12 Conditional Validation
Jul 07, 2025
Mastering Laravel 12 Conditional Validation Laravel 12's validation system is super powerful, and conditional validation makes your forms...
The Difference Between Redux, Context & React Components in State Management
Aug 06, 2025
When building applications with React, there’s always a need to manage data that changes based on user interaction or from fetching external r...
Guide to Scroll‑Driven Animations with CSS
Jun 26, 2025
Guide to Scroll‑Driven Animations with CSS CSS animations can now be linked to user scrolling without any JavaScript — just pure CSS. 1. Thr...
React Hooks Complete Guide
Jul 01, 2025
🎣 Complete React Hooks Guide with Practical Examples 🧠useState What it does: Adds local state to a function component. Code Example: impo...