$name) { $asset = $service->create([ 'name' => $name, 'asset_status_id' => $status?->id, 'asset_class_id' => $class?->id, 'asset_category_id' => $category?->id, 'unit_id' => $unit?->id, 'department_id' => $dept?->id, 'person_in_charge_id' => $pic?->id, 'asset_user_id' => $user?->id, 'asset_location_id' => $location?->id, 'warranty_id' => $warranty?->id, 'purchase_date' => now()->subDays(30 + $index), 'cost' => 1000000 + ($index * 250000), ]); // Download 2 foto berbeda untuk tiap aset dari pool. $pics = collect($imagePool)->shuffle()->take(2); foreach ($pics as $idx => $url) { $response = Http::get($url); if ($response->ok()) { $path = "assets/{$asset->id}/photo-{$idx}.jpg"; Storage::disk('public')->put($path, $response->body()); AssetPhoto::create([ 'asset_id' => $asset->id, 'path' => $path, 'is_primary' => $idx === 0 && $asset->photos()->count() === 0, ]); } } } } }