Count all feedback on all submits on specific post (Laravel)

I’m trying to count all the feedback that an user receives on his submits on a specific task, an user can submit multiple times on a task, here is a visualisation of the relation

Task:

public function submits()
{
return $this->hasMany(‘AppSubmit’, ‘task_id’);
}

Submit:

public function feedbacks()
{
return $this->hasMany(‘AppFeedback’, ‘submit_id’);
}

I would like to perform a code that would look like this

count($task->submits->feedbacks)->where(‘user_id’, $currentUser)

Does anyone have a solution for my problem,
would appreciate it!

Read more here:: Count all feedback on all submits on specific post (Laravel)

Leave a Reply

Your email address will not be published. Required fields are marked *