reminder for todos

This commit is contained in:
DigitalInfinity committed 2026-07-02 19:34:12 +00:00
1 parent f78740fbb0
commit ec6d7e2a80
9 files changed
+171 -27

No files matched your search

+16 -11
View File
@@ -2,16 +2,10 @@
namespace App\Observers;
use App\Mail\TodoAssigned;
use App\Mail\TodoCreated;
use App\Mail\TodoMail;
use App\Mail\TodoNeedsReview;
use App\Mail\TodoReopened;
use App\Models\Group;
use App\Models\Todo;
use App\Models\User;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Str;
class TodoObserver
{
@@ -20,12 +14,13 @@ class TodoObserver
*/
public function created(Todo $todo): void
{
if($todo->todoable_type == null) return;
// if($todo->todoable_type == User::class && $todo->user_id == $todo->todoable_id) return;
if($todo->todoable_type == User::class) {
Mail::to(User::find($todo->todoable()->first()))->send(new TodoMail($todo, 'Neue Todo', 'Es gibt eine neue Todo für dich:'));
if ($todo->todoable_type == null) {
return;
}
else {
// if($todo->todoable_type == User::class && $todo->user_id == $todo->todoable_id) return;
if ($todo->todoable_type == User::class) {
Mail::to(User::find($todo->todoable()->first()))->send(new TodoMail($todo, 'Neue Todo', 'Es gibt eine neue Todo für dich:'));
} else {
$users = $todo->todoable()->first()->users()->get();
foreach ($users as $user) {
Mail::to($user)->send(new TodoMail($todo, 'Neue Todo', 'Es gibt eine neue Todo für dich:'));
@@ -33,6 +28,16 @@ class TodoObserver
}
}
/**
* Handle the Todo "updating" event.
*/
public function updating(Todo $todo): void
{
if ($todo->isDirty('follow_up')) {
$todo->follow_up_notified_at = null;
}
}
/**
* Handle the Todo "updated" event.
*/