public function sync() { /** * find all products that are linked, * if it has update_queue == 1 it should stay online, * if not -> it should go offline */ $products = $this->product->with(array('sosProduct', 'sosProduct.prijsFabrikant'))->withTrashed()->linked()->get(); foreach ($products as $product) { //make sure the sosProduct still exists if ($product->sosProduct) { if ($product->update_queue == 1) { $this->updateProduct($product); } else { $this->takeProductOffline($product); } } } $this->resetQueue(); }