Help with Query to get check whether entry is first of its kind

Posted 2 years ago by jbowman99

I have an activities table, the table has fields

user_id,
customer_id
type

I want to check whether a activity of type close is the first time a specific user has closed and activity for a specific customer. i.e. users first closed sale to a client.

if it is the first activity i need to update another table.

so i have all the users activities where type='close'

$closes = Activity::where('type', 'close')->where('user_id', $user->id)->get();

not sure what to do next.

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