supplier_id = \App\Models\Supplier::where('hooreycaId', 'S740')->get()->first()->id; $priceList->status = DbStatusFieldEnum::active; $priceList->available = '2021-11-01'; $priceList->save(); Artisan::call('db:seed', [ '--class' => 'PriceListPriceSeeder', ]); return; $priceList = new PriceList; $priceList->supplier_id = \App\Models\Supplier::find(7)->id; $priceList->status = DbStatusFieldEnum::active; $priceList->available = '2021-11-01'; $priceList->save(); $products = Product::inRandomOrder()->take(rand(10, 35))->pluck('id'); foreach ($products as $product) { $priceList->products()->attach($product, ['price' => rand(10, 999)]); } $priceList->save(); $priceList = new PriceList; $priceList->supplier_id = \App\Models\Supplier::find(7)->id; $priceList->status = DbStatusFieldEnum::active; $priceList->available = Carbon::yesterday(); $priceList->save(); $products = Product::where('product_group_id', 50)->inRandomOrder()->take(rand(10, 35))->pluck('id'); $this->command->info('creating '.count($products).' price to 50 groupId product '); foreach ($products as $product) { $priceList->products()->attach($product, ['price' => rand(10, 999)]); } $priceList->save(); /* */ } }