Laravel PIVOT table with extra fields and withCount('table') not working as expected
问题 I've the following structure in my database. users -- id ... products -- id ... licenses (pivot table with some extra informations these data are grabbed via API) -- user_id product_id license_key license_type url purchased_at (datetime) supported_until (datetime) ... And here are codes in my model: # User has many licenses # User has many products through licenses User // User has many licenses. public function licenses() { return $this->hasMany(License::class); } Product Model. # Product