The error message suggests that the created_at column is ambiguous because it exists in both the transactions and customers tables. To resolve this, you can specify which table's created_at column you want to use in the whereHas method by prefixing it with the table name or alias. Here's an example:
$p = Customer::whereHas('transactions', function($query) use($request) {
$query->where('transactions.created_at', '>', $request->input('created_at'));
})->count();
In this example, we're using the where method to add a condition to the transactions relationship query. We're specifying the transactions.created_at column to avoid ambiguity. You can adjust the condition to fit your specific use case.
Note that if you're using a custom filter method on the query builder, you'll need to modify it to include the table name or alias for the created_at column as well.