nikunj kansara
nikunj kansara

Reputation: 17

Call repository function with entity manager but getting namespace error

I am calling repository function with following detail

$ratingData = $em->getRepository(PatientFeedback::class)->getRatingReviewData($doctorId, $this->timezone);

and my repository class is like:

namespace App\Repository;

class PatientFeedbackRepository extends ServiceEntityRepository
{
}

getting error like:

Attempted to call function \"getRatingReviewData\" from namespace \"Api\\Controller\".

is anything specific I am missing to use entity repository?

Upvotes: 0

Views: 497

Answers (2)

G1.3
G1.3

Reputation: 1879

You have a syntax error:

$em->getRepository(PatientFeedback::class)>getRatingReviewData(...)

to:

$em->getRepository(PatientFeedback::class)->getRatingReviewData(...)

Without the -, it's looking for a function nammed getRatingReviewData in the current namespace

Upvotes: 2

ankit parmar
ankit parmar

Reputation: 21

Use EntityRepository instead of ServiceEntityRepository :

    use Doctrine\ORM\EntityRepository;
    class UsersRepository extends EntityRepository

Upvotes: -1

Related Questions