Answer the question
In order to leave comments, you need to log in
How can I find out which model a sample belongs to?
Now the array includes those fields that are in the table (id, text).
Is it possible to somehow supplement this array, for each item, in order to
know which table this refers to?Post::all()
#perPage: 15
+exists: true
+wasRecentlyCreated: false
#attributes: array:2 [▼
"id" => 1
"text" => "Общие положения"
]
#original: array:2 [▶]
#changes: []
#casts: []
Answer the question
In order to leave comments, you need to log in
$collection->map(function ($item, $key) {
$item->setAttribute('table', $item->getTable());
});
public function getTableAttribute()
{
return $this->getTable();
}
Why merge something and then filter? You can not transfer two (or how many you have there) different collections or what?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question