how to push object inside array laravel php

  laravel, laravel-collection

i did query from db and return array

$games = Game::where('admin_id', $user->id)->where('active', true)->get();

now i am trying to add object inside $games array like this

$games->push(['name' => 'Game1', 'color' => 'red']); //its adding array instead object

please explain Thank you

Source: Laravel

Leave a Reply