mardi 6 août 2019

Passing an element of a collection in the query builder

I would like to make a second request with the id obtained in the previous request.

I have 3 tables: - organization - users - follow_organization (relationship table)

I would like to obtain the number of occurrences in the follow_organization table by passing the id of the organization previously obtained.

$organization = DB::table('organizations')->where('name', $name)->first();
$followers = DB::table('follow_organizations')->where('organization_id', $organization)->count();

Unfortunately I get the following error message:

Object of class stdClass could not be converted to string.

I understood the problem, I pass a table while the query builder waits for a string. But I can't find the solution to this problem despite the tons of answers I've read on the internet.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire