src/Services/LikeableService.php
public function fetchLikesCounters($likeableType, $likeType)
    {
        /** @var \Illuminate\Database\Eloquent\Builder $likesCount */
        $likesCount = app(LikeContract::class)
            ->select([
                DB::raw('COUNT(*) AS count'),
                'likeable_type',
                'likeable_id',
                'type_id',
            ])
            ->where('likeable_type', $likeableType);

        if (!is_null($likeType)) {
            $likesCount->where('type_id', $this->getLikeTypeId($likeType));
        }

        $likesCount->groupBy('likeable_id', 'type_id');

        return $likesCount->get()->toArray();
    }
public function fetchLikesCounters($likeableType, $likeType)
    {
        /** @var \Illuminate\Database\Eloquent\Builder $likesCount */
        $likesCount = app(LikeContract::class)
            ->select([
                DB::raw('COUNT(*) AS count'),
                'likeable_type',
                'likeable_id',
                'type_id',
            ])
            ->where('likeable_type', $likeableType);

        if (!is_null($likeType)) {
            $likesCount->where('type_id', $this->getLikeTypeId($likeType));
        }

        $likesCount->groupBy('likeable_id', 'type_id');

        return $likesCount->get()->toArray();
    }
public function fetchLikesCounters ( $ likeableType , $ likeType ) { /** @var \Illuminate\Database\Eloquent\Builder $likesCount */ $ likesCount = app ( LikeContract :: class ) -> select ( [ DB :: raw ( 'COUNT(*) AS count' ) , 'likeable_type' , 'likeable_id' , 'type_id' , ] ) -> where ( 'likeable_type' , $ likeableType ) ; if ( ! is_null ( $ likeType ) ) { $ likesCount -> where ( 'type_id' , $ this -> getLikeTypeId ( $ likeType ) ) ; } $ likesCount -> groupBy ( 'likeable_id' , 'type_id' ) ; return $ likesCount -> get ( ) -> toArray ( ) ; }
Fetch likes counters data.

@param string $likeableType
@param string $likeType
@return array

@throws \Cog\Likeable\Exceptions\LikeTypeInvalidException
Fetch likes counters data .