The whereIn method should be called on the query builder instance, not on a column name. Here's the corrected query:
$hasBorrowedCars = CarBorrow::query()
->where('borrowed_from_user_id', $userId)
->join('car_owners', 'car_borrows.car_id', '=', 'car_owners.car_id')
->whereIn('car_owners.user_id', [$userId])
->exists();
This query will join the car_owners table on the car_id column, and then filter the results to only include rows where the user_id column is equal to $userId. The whereIn method is used to specify the list of user IDs to match against.
Note that I also added the car_borrows.car_id column to the join condition, assuming that this is the column that links the car_borrows and car_owners tables. If this is not the case, you'll need to adjust the join condition accordingly.