Answer the question
In order to leave comments, you need to log in
Laravel 5.4 how to modify an Eloquent object when a query is executed?
There are User and Field models,
the
hasMany relationship (a user can have many fields)
Field has Name and Value fields (for example, first_name and Vasya) In this case, the $user->first_name property should appear (or $user->fields->first_name, it doesn't matter)
If you make a request users()->with('fields')->get(), then the user gets the fields property , but it has a simple array, but it doesn’t suit me, I need at least an associative one with keys by Name
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