sunel / eav

Entity–attribute–value model (EAV) for Laravel Artisan
https://sunel.github.io/eav/
143 stars 39 forks source link

How to use wthCount, withSum and so on #63

Open smilelanss opened 2 years ago

smilelanss commented 2 years ago

Hi @sunel $organizations = OrganizationEav::withCount('comments' )->get(); withCount don't work. Is there a solution to this problem?

error SQLSTATE[08P01]: <<Unknown error>>: 7 ERROR: bind message supplies 11 parameters, but prepared statement "pdo_stmt_00000013" requires 13 (SQL: select (select count(*) from "comments" where "organizations"."id" = "comments"."commentable_id" and "comments"."commentable_type" = organization and "status" = PUBLISHED and "parent_id" is null) as "comments_count"

sunel commented 2 years ago

@smilelanss

Can you post the class blueprint here

smilelanss commented 2 years ago

@sunel Class: use App\EavModels\Organization as OrganizationEav;

Model:

use Eav\Model;
class Organization extends Model