laravelschedulelaravel-scheduler

Laravel Schedule daily notification for each user on their preferred time


I'm developing a task management app. I need to send a daily report notification at the user's preferred time. I did check Laravel features such as Task Scheduling and etc. But I don't find the right solution. If I want to use Schedule I have to write a foreach containing all with all my users and check if it's the time to notify, every single minute, which won't be efficient!

       //Not Efficient Code:
       $schedule->call(function (){
            foreach(User::all() as $user){
                if ($user->preferred_time == now()){
                    $user->notify(new Notification);
                }
            }
        }
        )->everyMinute();

Solution

  • I ended up finding this package which has convenient solutions for my situation: Laravel Snooze