Answer the question
In order to leave comments, you need to log in
How to make correctly polymorphic connections and relationships?
There are 3 models: Document, Status, ApprovalAttempt.
documents
id - integer
name - string
statuses
id - integer
approval_attempt_id - integer (foreign key)
approval_attempts
id - integer
approvable_type - string
approvable_id - integer
->statuses
and get all document statuses (document ID in approval_attempts, ID ApprovalAttempt in the statuses table). public function statuses()
{
return $this->approvalAttempts()->statuses();
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question