I've a very big doubt about how works laravel for a very simple thing:
If I call:
$companies=User::All();
Then I can use statement like this in a forach
:
foreach($companies as $company)
$company['new_field']= 'something';
If i'm limiting the output of the query like:
$companies = DB::table('companies')
->select('id','name','email','business_name',...)->get();
The things doesnt work as before,
- I try with or without the
->get()
- I try to convert with
->toArray()
(errors rised) - I try with
put() and push()
for collections method and agains errors...
How can I add a field in every item of the collection just to pass it to a view?