2 years ago

Using Carbon inside of an Eloquent Scope

Posted 2 years ago by Breki

I've got a database table for recurring tasks which contains (amongst others) a LastCompleted and a Frequency column, where one can easily see how Carbon::parse($Schedule->LastCompleted)->addMinutes($Schedule->Frequency) would give us the time that that particular event is supposed to run again.

However, I'm trying to write a scopeOverdue inside of that model, and I can't figure out how best to write it. How do I access two fields from the same model and apply some Carbon-logic to them and then only return the fields that match?

Please sign in or create an account to participate in this conversation.