So I'm checking to see that a "tag" has expired 7 days ago. But I also want to make sure that there aren't any other tags that are still valid within the same query. So, if there are other tags connected to the user that the tag is "active = 1" AND expiry_date is still in the future (tomorrow, at least), ignore that users tags altogether.
I've got the first part working fine:
$seven_days_ago_start = date('Y-m-d', strtotime('-7 days')) . ' 00:00:01';
$seven_days_ago_end = date('Y-m-d', strtotime('-7 days')) . ' 23:59:59';
$expired_tags = DB::table('tags')
->leftJoin('users', 'tags.user_id', '=', 'users.id')
->leftJoin('pets', 'pets.id', '=', 'tags.pet_id')
->where('tags.active', '=', 1)
->whereBetween('tags.expiry_date', array($seven_days_ago_start, $seven_days_ago_end))
->select('users.id', 'users.username', 'users.email', 'users.first_name', 'tags.serial_number')
->get();
I hoping someone is able to help me out with this... I really don't know the best way to construct this query.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community