Convert model method to eloquent relationship
imagine this scenario
tables:
eloquent relations:
right now, using only eloquent relations, i can know which is the latest and also which is the oldest user linked to the task.
this is how it would look like the task model but wrong for this case, since they return
?User
, but as i said, i need the methods to return eloquent relationships:
as you have noticed this is a has many relationship. and it works fine.
but my question is how to translate this into a belongs to many relationship.
as in the has many relationship case, for the belongs to many relationship i want:
- to be able to retrieve task's users as an eloquent relationship
- to be able to retrieve task's first user as an eloquent relationship
- to be able to retrieve task's oldest user as an eloquent relationship1 Reply
bump