M
M
Michael2017-05-05 10:11:04
Laravel
Michael, 2017-05-05 10:11:04

How to deploy a collection in Laravel?

Hello!
Can you please tell me how you can expand the collection to access the elements of the request?
The gist is the following:

  1. I make the following query to the database
    foreach ($id as $mac)
            {
                $nic[] = Networkcard::select(['mac', 'name', 'network', 'wol'])->where('mac',$mac)->get();
            }

  2. I get the following result

33c3d384b24644c296dabe7effe141cb.PNG
If expanded.
d79ecfb3e7b24dd580263fb00e63b2b0.PNG
Expanding the collection, there is another 1 nesting of Items and you have to do a double nested foreach . Tell me please, can there be an opportunity to somehow change the request or directly access the fields in the model?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
Finsh, 2017-05-05
@MikhailBond

Networkcard::select(['mac', 'name', 'network', 'wol'])->whereIn('mac',$id)->get();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question