public function UpdateImpresorasList() { $client = new Client(); $crawler = $client->request('GET', 'http://10.128.2.16/tinta/printers.php?sort=printers.server&dir=asc'); $nodos = $crawler->filter('td'); $i = 1; $listaimpresoras = new Collection(); foreach ($nodos as $key => $domElement) { if ($i == $key) { $i += 7; $imp = new \stdClass(); $modelo_impresora = $domElement->nodeValue; $listaimpresoras->push($modelo_impresora); $impresora = Impresora::where('modelo_impresora', $modelo_impresora)->first(); if (empty($impresora)) { $impresora = new Impresora(); $impresora->modelo_impresora = $modelo_impresora; $impresora->save(); } } } /*foreach ($variable as $key => $value) { # code... } */ }