James Parsons
James Parsons

Reputation: 925

How to count the number of rows coming out of a too many relationships where there are two conditions in Laravel

I am looking to count the number of rows coming out of a too many relationships where there are two conditions. The query is below:

$follow = count($profiles->follow->where('follow_id', $account)->where('user_id', $user));

I currently have entries in follow_id as 17 and in the user_id as 16.

A dump of $account and $user shows the data is correct.

The result is currently coming back as 0 where I am looking for it to be 1.

Thanks

Upvotes: 0

Views: 31

Answers (1)

Ernesto Hernández
Ernesto Hernández

Reputation: 255

try

$follow = $profiles->follow->where('follow_id', $account)->where('user_id', $user)->count();

Upvotes: 1

Related Questions