/** * Create a variant for each product that does not have any. */ public function initialiseProductOptions() { /** @var Product $product */ foreach (Product::has('options', '<', 1)->get() as $product) { echo "Creating option for product {$product->id}\n"; $product->options()->save(new ProductOption(['label' => 'Standard'])); } }