Answer the question
In order to leave comments, you need to log in
How to implement history many-to-many relationship in laravel?
Good evening. Prompt how correctly to implement communication between models. I have an Apply request model and a Status model. A many-to-many relationship (belongsToMany). The link table has additional fields such as comment, user_id. It is necessary to make the connection in such a way that I could access the current status through the magic property $Apply->status
and use
$Apply->status()->where('...', '...')->get() // и тому подобное
. $Apply->statuses
doing$Apply->statuses()->where('...', '...')->get() // и тому подобное
Answer the question
In order to leave comments, you need to log in
Solved the issue by double linking. Made a table for the StatusHistory model
status_history
- increment id
- integer status_id
- integer apply_id
- integer user_id
- string comment
- timestamps
applies
- increment id
- .....
- status_id
apply_statuses
- increment id
- string title
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question