How to check relationship exist for Eloequent polymorphic?

Viewed 962

Hi how can I check for Eloquent polymorphic relationship already exist?

For example, I want to prevent data with same upload_id, attachable_id and attachable_type from getting store in the attachments table (refer to the highlight)

What I have try but did not get correct count of relationship exist:

//get count of attachment
$application->has('attachments')->count()

enter image description here

1 Answers
Related