I am trying to send a notification to the enrolled users in an event a day before the event's start date. I have a user table events table that contains the start date of each event. Also, I have an enrollment table that includes the user_id and event_id as foreign keys and the start date of these events. However, while I was trying to code the logic of this function and executing it, I got this error.
class SendNotification extends Command
You are using collection when you call Model::all() and you are trying to use it like an array but it is a collection.
$enrolls = Enroll::all()->keyBy('user_id')->all();
then run your if check like
if (isset($enrolls[$user->id]))
I can not copy your code because you shared screenshot not a code. So be aware of that for your next question.