diff --git a/packages/Webkul/Core/src/Database/Factories/CategoryFactory.php b/packages/Webkul/Core/src/Database/Factories/CategoryFactory.php deleted file mode 100644 index 941601997..000000000 --- a/packages/Webkul/Core/src/Database/Factories/CategoryFactory.php +++ /dev/null @@ -1,19 +0,0 @@ -define(Category::class, function (Faker $faker, array $attributes) { - - return [ - 'status' => 1, - 'position' => $faker->randomDigit, - 'parent_id' => 1, - ]; -}); - -$factory->state(Category::class, 'inactive', [ - 'status' => 0, -]); diff --git a/packages/Webkul/Core/src/Database/Factories/InventorySourceFactory.php b/packages/Webkul/Core/src/Database/Factories/InventorySourceFactory.php deleted file mode 100644 index 1f63b1333..000000000 --- a/packages/Webkul/Core/src/Database/Factories/InventorySourceFactory.php +++ /dev/null @@ -1,28 +0,0 @@ -define(InventorySource::class, function (Faker $faker) { - $now = date("Y-m-d H:i:s"); - $code = $faker->unique()->word; - return [ - 'code' => $faker->unique()->word, - 'name' => $code, - 'description' => $faker->sentence, - 'contact_name' => $faker->name, - 'contact_email' => $faker->safeEmail, - 'contact_number' => $faker->phoneNumber, - 'country' => $faker->countryCode, - 'state' => $faker->state, - 'city' => $faker->city, - 'street' => $faker->streetAddress, - 'postcode' => $faker->postcode, - 'priority' => 0, - 'status' => 1, - 'created_at' => $now, - 'updated_at' => $now, - ]; -}); diff --git a/packages/Webkul/Core/src/Database/Factories/InvoiceFactory.php b/packages/Webkul/Core/src/Database/Factories/InvoiceFactory.php deleted file mode 100644 index 731acee97..000000000 --- a/packages/Webkul/Core/src/Database/Factories/InvoiceFactory.php +++ /dev/null @@ -1,71 +0,0 @@ -define(Invoice::class, function (Faker $faker, array $attributes) { - - $availableStatus = [ - 'pending', - 'paid', - 'refunded', - ]; - - $subTotal = $faker->randomFloat(2); - - $shippingAmount = $faker->randomFloat(2); - - $taxAmount = $faker->randomFloat(2); - - if (! $attributes['order_id']) { - $attributes['order_id'] = function () { - return factory(Order::class)->create()->id; - }; - } - - if (! $attributes['order_address_id']) { - $attributes['order_address_id'] = function () use ($attributes) { - return factory(OrderAddress::class) - ->create(['order_id' => $attributes['order_id']]) - ->id; - }; - } - - return [ - 'status' => array_rand($availableStatus), - 'email_sent' => 0, - 'total_qty' => $faker->randomNumber(), - 'base_currency_code' => 'EUR', - 'channel_currency_code' => 'EUR', - 'order_currency_code' => 'EUR', - 'sub_total' => $subTotal, - 'base_sub_total' => $subTotal, - 'grand_total' => $subTotal, - 'base_grand_total' => $subTotal, - 'shipping_amount' => $shippingAmount, - 'base_shipping_amount' => $shippingAmount, - 'tax_amount' => $taxAmount, - 'base_tax_amount' => $taxAmount, - 'discount_amount' => 0, - 'base_discount_amount' => 0, - 'order_id' => $attributes['order_id'], - 'order_address_id' => $attributes['order_address_id'], - ]; -}); - -$factory->state(Invoice::class, 'pending', [ - 'status' => 'pending', -]); - -$factory->state(Invoice::class, 'paid', [ - 'status' => 'paid', -]); - -$factory->state(Invoice::class, 'refunded', [ - 'status' => 'refunded', -]); - diff --git a/packages/Webkul/Core/src/Database/Factories/InvoiceItemFactory.php b/packages/Webkul/Core/src/Database/Factories/InvoiceItemFactory.php deleted file mode 100644 index 21cd87411..000000000 --- a/packages/Webkul/Core/src/Database/Factories/InvoiceItemFactory.php +++ /dev/null @@ -1,41 +0,0 @@ -define(InvoiceItem::class, function (Faker $faker, array $attributes) { - - $basePrice = $faker->randomFloat(2); - $quantity = $faker->randomNumber(); - - if (! $attributes['order_item_id']) { - $attributes['order_item_id'] = function () { - return factory(OrderItem::class)->create()->id; - }; - } - - $orderItem = OrderItem::find($attributes['order_item_id']); - - return [ - 'name' => $faker->word, - 'sku' => $faker->unique()->ean13, - 'qty' => $quantity, - 'price' => $basePrice, - 'base_price' => $basePrice, - 'total' => $quantity * $basePrice, - 'base_total' => $quantity * $basePrice, - 'tax_amount' => 0, - 'base_tax_amount' => 0, - 'product_id' => $orderItem->product_id, - 'product_type' => $orderItem->product_type, - 'order_item_id' => $attributes['order_item_id'], - 'invoice_id' => function () { - return factory(Invoice::class)->create()->id; - }, - ]; -}); diff --git a/packages/Webkul/Core/src/Database/Factories/LocaleFactory.php b/packages/Webkul/Core/src/Database/Factories/LocaleFactory.php deleted file mode 100644 index 0ab390c2f..000000000 --- a/packages/Webkul/Core/src/Database/Factories/LocaleFactory.php +++ /dev/null @@ -1,19 +0,0 @@ -define(Locale::class, function (Faker $faker, array $attributes) { - - return [ - 'code' => $faker->languageCode, - 'name' => $faker->country, - 'direction' => 'ltr', - ]; -}); - -$factory->state(Category::class, 'rtl', [ - 'direction' => 'rtl', -]); diff --git a/packages/Webkul/Core/src/Database/Factories/OrderAddressFactory.php b/packages/Webkul/Core/src/Database/Factories/OrderAddressFactory.php deleted file mode 100644 index 9edb89dbd..000000000 --- a/packages/Webkul/Core/src/Database/Factories/OrderAddressFactory.php +++ /dev/null @@ -1,35 +0,0 @@ -define(OrderAddress::class, function (Faker $faker) { - $now = date("Y-m-d H:i:s"); - $customer = factory(Customer::class)->create(); - $customerAddress = factory(CustomerAddress::class)->create(); - return [ - 'first_name' => $customer->first_name, - 'last_name' => $customer->last_name, - 'email' => $customer->email, - 'address1' => $customerAddress->address1, - 'country' => $customerAddress->country, - 'state' => $customerAddress->state, - 'city' => $customerAddress->city, - 'postcode' => $customerAddress->postcode, - 'phone' => $customerAddress->phone, - 'address_type' => 'billing', - 'order_id' => function () { - return factory(Order::class)->create()->id; - }, - 'created_at' => $now, - 'updated_at' => $now, - ]; -}); - -$factory->state(OrderAddress::class, 'shipping', [ - 'address_type' => 'shipping', -]); \ No newline at end of file diff --git a/packages/Webkul/Core/src/Database/Factories/OrderFactory.php b/packages/Webkul/Core/src/Database/Factories/OrderFactory.php deleted file mode 100644 index 5f813145c..000000000 --- a/packages/Webkul/Core/src/Database/Factories/OrderFactory.php +++ /dev/null @@ -1,68 +0,0 @@ -define(Order::class, function (Faker $faker) { - $now = date("Y-m-d H:i:s"); - - $lastOrder = DB::table('orders') - ->orderBy('id', 'desc') - ->select('id') - ->first(); - - $customer = factory(Customer::class)->create(); - - return [ - 'increment_id' => $lastOrder + 1, - 'status' => 'pending', - 'channel_name' => 'Default', - 'is_guest' => 0, - 'customer_id' => $customer->id, - 'customer_email' => $customer->email, - 'customer_first_name' => $customer->first_name, - 'customer_last_name' => $customer->last_name, - 'is_gift' => 0, - 'total_item_count' => 1, - 'total_qty_ordered' => 1, - 'base_currency_code' => 'EUR', - 'channel_currency_code' => 'EUR', - 'order_currency_code' => 'EUR', - 'grand_total' => 0.0000, - 'base_grand_total' => 0.0000, - 'grand_total_invoiced' => 0.0000, - 'base_grand_total_invoiced' => 0.0000, - 'grand_total_refunded' => 0.0000, - 'base_grand_total_refunded' => 0.0000, - 'sub_total' => 0.0000, - 'base_sub_total' => 0.0000, - 'sub_total_invoiced' => 0.0000, - 'base_sub_total_invoiced' => 0.0000, - 'sub_total_refunded' => 0.0000, - 'base_sub_total_refunded' => 0.0000, - 'customer_type' => Customer::class, - 'channel_id' => 1, - 'channel_type' => Channel::class, - 'created_at' => $now, - 'updated_at' => $now, - 'cart_id' => 0, - ]; -}); - -$factory->state(Order::class, 'pending', [ - 'status' => 'pending', -]); - -$factory->state(Order::class, 'completed', [ - 'status' => 'completed', -]); - -$factory->state(Order::class, 'closed', [ - 'status' => 'closed', -]); diff --git a/packages/Webkul/Core/src/Database/Factories/OrderItemFactory.php b/packages/Webkul/Core/src/Database/Factories/OrderItemFactory.php deleted file mode 100644 index c9a4fc635..000000000 --- a/packages/Webkul/Core/src/Database/Factories/OrderItemFactory.php +++ /dev/null @@ -1,38 +0,0 @@ -define(OrderItem::class, function (Faker $faker) { - $now = date("Y-m-d H:i:s"); - - $product = factory(Product::class, 'simple')->create(); - - return [ - 'sku' => $product->sku, - 'type' => $product->type, - 'name' => $product->name, - 'price' => $product->price, - 'base_price' => $product->price, - 'total' => $product->price, - 'base_total' => $product->price, - 'product_id' => $product->id, - 'qty_ordered' => 1, - 'qty_shipped' => 0, - 'qty_invoiced' => 0, - 'qty_canceled' => 0, - 'qty_refunded' => 0, - 'order_id' => function () { - return factory(Order::class)->create()->id; - }, - 'created_at' => $now, - 'updated_at' => $now, - ]; -}); - - - diff --git a/packages/Webkul/Core/src/Database/Factories/ProductAttributeValueFactory.php b/packages/Webkul/Core/src/Database/Factories/ProductAttributeValueFactory.php deleted file mode 100644 index 65e5e6245..000000000 --- a/packages/Webkul/Core/src/Database/Factories/ProductAttributeValueFactory.php +++ /dev/null @@ -1,276 +0,0 @@ -defineAs(ProductAttributeValue::class, 'sku', function (Faker $faker) { - return [ - 'product_id' => function () { - return factory(Product::class)->create()->id; - }, - 'text_value' => $faker->uuid, - 'attribute_id' => 1, - ]; -}); - -$factory->defineAs(ProductAttributeValue::class, 'name', function (Faker $faker) { - return [ - 'product_id' => function () { - return factory(Product::class)->create()->id; - }, - 'locale' => 'en', //$faker->languageCode, - 'channel' => 'default', - 'text_value' => $faker->words(2, true), - 'attribute_id' => 2, - ]; -}); - -$factory->defineAs(ProductAttributeValue::class, 'url_key', function (Faker $faker) { - return [ - 'product_id' => function () { - return factory(Product::class)->create()->id; - }, - 'text_value' => $faker->unique()->slug, - 'attribute_id' => 3, - ]; -}); - -$factory->defineAs(ProductAttributeValue::class, 'tax_category_id', function (Faker $faker) { - return [ - 'product_id' => function () { - return factory(Product::class)->create()->id; - }, - 'channel' => 'default', - 'integer_value' => null, // ToDo - 'attribute_id' => 4, - ]; -}); - -$factory->defineAs(ProductAttributeValue::class, 'new', function (Faker $faker) { - return [ - 'product_id' => function () { - return factory(Product::class)->create()->id; - }, - 'boolean_value' => 1, - 'attribute_id' => 5, - ]; -}); - -$factory->defineAs(ProductAttributeValue::class, 'featured', function (Faker $faker) { - return [ - 'product_id' => function () { - return factory(Product::class)->create()->id; - }, - 'boolean_value' => 1, - 'attribute_id' => 6, - ]; -}); - -$factory->defineAs(ProductAttributeValue::class, 'visible_individually', function (Faker $faker) { - return [ - 'product_id' => function () { - return factory(Product::class)->create()->id; - }, - 'boolean_value' => 1, - 'attribute_id' => 7, - ]; -}); - -$factory->defineAs(ProductAttributeValue::class, 'status', function (Faker $faker) { - return [ - 'product_id' => function () { - return factory(Product::class)->create()->id; - }, - 'boolean_value' => 1, - 'attribute_id' => 8, - ]; -}); - -$factory->defineAs(ProductAttributeValue::class, 'short_description', function (Faker $faker) { - return [ - 'product_id' => function () { - return factory(Product::class)->create()->id; - }, - 'locale' => 'en', //$faker->languageCode, - 'channel' => 'default', - 'text_value' => $faker->sentence, - 'attribute_id' => 9, - ]; -}); - -$factory->defineAs(ProductAttributeValue::class, 'description', function (Faker $faker) { - return [ - 'product_id' => function () { - return factory(Product::class)->create()->id; - }, - 'locale' => 'en', //$faker->languageCode, - 'channel' => 'default', - 'text_value' => $faker->sentences(3, true), - 'attribute_id' => 10, - ]; -}); - -$factory->defineAs(ProductAttributeValue::class, 'price', function (Faker $faker) { - return [ - 'product_id' => function () { - return factory(Product::class)->create()->id; - }, - 'float_value' => $faker->randomFloat(4, 0, 1000), - 'attribute_id' => 11, - ]; -}); - -$factory->defineAs(ProductAttributeValue::class, 'cost', function (Faker $faker) { - return [ - 'product_id' => function () { - return factory(Product::class)->create()->id; - }, - 'channel' => 'default', - 'float_value' => $faker->randomFloat(4, 0, 10), - 'attribute_id' => 12, - ]; -}); - -$factory->defineAs(ProductAttributeValue::class, 'special_price', function (Faker $faker) { - return [ - 'product_id' => function () { - return factory(Product::class)->create()->id; - }, - 'float_value' => $faker->randomFloat(4, 0, 100), - 'attribute_id' => 13, - ]; -}); - -$factory->defineAs(ProductAttributeValue::class, 'special_price_from', function (Faker $faker) { - return [ - 'product_id' => function () { - return factory(Product::class)->create()->id; - }, - 'channel' => 'default', - 'date_value' => $faker->dateTimeBetween('-5 days', 'now', 'Europe/Berlin'), - 'attribute_id' => 14, - ]; -}); - -$factory->defineAs(ProductAttributeValue::class, 'special_price_to', function (Faker $faker) { - return [ - 'product_id' => function () { - return factory(Product::class)->create()->id; - }, - 'channel' => 'default', - 'date_value' => $faker->dateTimeBetween('now', '+ 5 days', 'Europe/Berlin'), - 'attribute_id' => 15, - ]; -}); - -$factory->defineAs(ProductAttributeValue::class, 'meta_title', function (Faker $faker) { - return [ - 'product_id' => function () { - return factory(Product::class)->create()->id; - }, - 'locale' => 'en', //$faker->languageCode, - 'channel' => 'default', - 'text_value' => $faker->words(2, true), - 'attribute_id' => 16, - ]; -}); - - -$factory->defineAs(ProductAttributeValue::class, 'meta_keywords', function (Faker $faker) { - return [ - 'product_id' => function () { - return factory(Product::class)->create()->id; - }, - 'locale' => 'en', //$faker->languageCode, - 'channel' => 'default', - 'text_value' => $faker->words(5, true), - 'attribute_id' => 17, - ]; -}); - -$factory->defineAs(ProductAttributeValue::class, 'meta_description', function (Faker $faker) { - return [ - 'product_id' => function () { - return factory(Product::class)->create()->id; - }, - 'locale' => 'en', //$faker->languageCode, - 'channel' => 'default', - 'text_value' => $faker->sentence, - 'attribute_id' => 18, - ]; -}); -$factory->defineAs(ProductAttributeValue::class, 'width', function (Faker $faker) { - return [ - 'product_id' => function () { - return factory(Product::class)->create()->id; - }, - 'integer_value' => $faker->numberBetween(1, 50), - 'attribute_id' => 19, - ]; -}); - -$factory->defineAs(ProductAttributeValue::class, 'height', function (Faker $faker) { - return [ - 'product_id' => function () { - return factory(Product::class)->create()->id; - }, - 'integer_value' => $faker->numberBetween(1, 50), - 'attribute_id' => 20, - ]; -}); - -$factory->defineAs(ProductAttributeValue::class, 'depth', function (Faker $faker) { - return [ - 'product_id' => function () { - return factory(Product::class)->create()->id; - }, - 'integer_value' => $faker->numberBetween(1, 50), - 'attribute_id' => 21, - ]; -}); - -$factory->defineAs(ProductAttributeValue::class, 'weight', function (Faker $faker) { - return [ - 'product_id' => function () { - return factory(Product::class)->create()->id; - }, - 'integer_value' => $faker->numberBetween(1, 50), - 'attribute_id' => 22, - ]; -}); - -$factory->defineAs(ProductAttributeValue::class, 'color', function (Faker $faker) { - return [ - 'product_id' => function () { - return factory(Product::class)->create()->id; - }, - 'integer_value' => $faker->numberBetween(1, 5), - 'attribute_id' => 23, - ]; -}); - -$factory->defineAs(ProductAttributeValue::class, 'size', function (Faker $faker) { - return [ - 'product_id' => function () { - return factory(Product::class)->create()->id; - }, - 'integer_value' => $faker->numberBetween(1, 5), - 'attribute_id' => 24, - ]; -}); - -$factory->defineAs(ProductAttributeValue::class, 'brand', function (Faker $faker) { - return [ - 'product_id' => function () { - return factory(Product::class)->create()->id; - }, - 'attribute_id' => 25, - 'integer_value' => function () { - return factory(AttributeOption::class)->create()->id; - }, - ]; -}); diff --git a/packages/Webkul/Core/src/Database/Factories/ProductDownloadableLinkFactory.php b/packages/Webkul/Core/src/Database/Factories/ProductDownloadableLinkFactory.php deleted file mode 100644 index 67bace113..000000000 --- a/packages/Webkul/Core/src/Database/Factories/ProductDownloadableLinkFactory.php +++ /dev/null @@ -1,31 +0,0 @@ -define(ProductDownloadableLink::class, function (Faker $faker) { - $now = date("Y-m-d H:i:s"); - $filename = 'ProductImageExampleForUpload.jpg'; - $filepath = '/tests/_data/'; - return [ - 'url' => '', - 'file' => $filepath . $filename, - 'file_name' => $filename, - 'type' => 'file', - 'price' => 0.0000, - 'downloads' => $faker->randomNumber(1), - 'created_at' => $now, - 'updated_at' => $now, - ]; -}); - -$factory->define(ProductDownloadableLinkTranslation::class, function (Faker $faker) { - return [ - 'locale' => 'en', - 'title' => $faker->word, - ]; -}); - diff --git a/packages/Webkul/Core/src/Database/Factories/ProductDownloadableSampleFactory.php b/packages/Webkul/Core/src/Database/Factories/ProductDownloadableSampleFactory.php deleted file mode 100644 index e22ece061..000000000 --- a/packages/Webkul/Core/src/Database/Factories/ProductDownloadableSampleFactory.php +++ /dev/null @@ -1,29 +0,0 @@ -define(ProductDownloadableSample::class, function (Faker $faker) { - $now = date("Y-m-d H:i:s"); - $filename = 'ProductImageExampleForUpload.jpg'; - $filepath = '/tests/_data/'; - return [ - 'url' => '', - 'file' => $filepath . $filename, - 'file_name' => $filename, - 'type' => 'file', - 'created_at' => $now, - 'updated_at' => $now, - ]; -}); - -$factory->define(ProductDownloadableSampleTranslation::class, function (Faker $faker) { - return [ - 'locale' => 'en', - 'title' => $faker->word, - ]; -}); - diff --git a/packages/Webkul/Core/src/Database/Factories/ProductFactory.php b/packages/Webkul/Core/src/Database/Factories/ProductFactory.php deleted file mode 100644 index f947a4ce6..000000000 --- a/packages/Webkul/Core/src/Database/Factories/ProductFactory.php +++ /dev/null @@ -1,28 +0,0 @@ -define(Product::class, function (Faker $faker) { - $now = date("Y-m-d H:i:s"); - return [ - 'sku' => $faker->uuid, - 'created_at' => $now, - 'updated_at' => $now, - 'attribute_family_id' => 1, - ]; -}); - -$factory->state(Product::class, 'simple', [ - 'type' => 'simple', -]); - -$factory->state(Product::class, 'virtual_nos', [ - 'type' => 'virtual_nos', -]); - -$factory->state(Product::class, 'downloadable_with_stock', [ - 'type' => 'downloadable_with_stock', -]); diff --git a/packages/Webkul/Core/src/Database/Factories/ProductInventoryFactory.php b/packages/Webkul/Core/src/Database/Factories/ProductInventoryFactory.php deleted file mode 100644 index eee69e31d..000000000 --- a/packages/Webkul/Core/src/Database/Factories/ProductInventoryFactory.php +++ /dev/null @@ -1,22 +0,0 @@ -define(ProductInventory::class, function (Faker $faker) { - return [ - 'qty' => $faker->numberBetween(1, 20), - 'product_id' => function () { - return factory(Product::class)->create()->id; - }, - 'inventory_source_id' => function () { - return factory(InventorySource::class)->create()->id; - }, - //'vendor_id' => 0, // this is default in DB schema - ]; -}); - diff --git a/packages/Webkul/Core/src/Providers/CoreServiceProvider.php b/packages/Webkul/Core/src/Providers/CoreServiceProvider.php index 949e565b4..658ff9768 100755 --- a/packages/Webkul/Core/src/Providers/CoreServiceProvider.php +++ b/packages/Webkul/Core/src/Providers/CoreServiceProvider.php @@ -37,8 +37,6 @@ class CoreServiceProvider extends ServiceProvider ]); SliderProxy::observe(SliderObserver::class); - - $this->registerEloquentFactoriesFrom(__DIR__ . '/../Database/Factories'); } /** @@ -64,15 +62,4 @@ class CoreServiceProvider extends ServiceProvider return app()->make(Core::class); }); } - - /** - * Register factories. - * - * @param string $path - * @return void - */ - protected function registerEloquentFactoriesFrom($path): void - { - $this->app->make(EloquentFactory::class)->load($path); - } -} \ No newline at end of file +} diff --git a/packages/Webkul/Core/src/Database/Factories/CustomerAddressFactory.php b/packages/Webkul/Customer/src/Database/Factories/CustomerAddressFactory.php similarity index 100% rename from packages/Webkul/Core/src/Database/Factories/CustomerAddressFactory.php rename to packages/Webkul/Customer/src/Database/Factories/CustomerAddressFactory.php diff --git a/packages/Webkul/Core/src/Database/Factories/CustomerFactory.php b/packages/Webkul/Customer/src/Database/Factories/CustomerFactory.php similarity index 100% rename from packages/Webkul/Core/src/Database/Factories/CustomerFactory.php rename to packages/Webkul/Customer/src/Database/Factories/CustomerFactory.php diff --git a/packages/Webkul/Customer/src/Providers/CustomerServiceProvider.php b/packages/Webkul/Customer/src/Providers/CustomerServiceProvider.php index 668eea895..9e62f6655 100755 --- a/packages/Webkul/Customer/src/Providers/CustomerServiceProvider.php +++ b/packages/Webkul/Customer/src/Providers/CustomerServiceProvider.php @@ -16,5 +16,18 @@ class CustomerServiceProvider extends ServiceProvider $this->loadTranslationsFrom(__DIR__ . '/../Resources/lang', 'customer'); $this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations'); + + $this->registerEloquentFactoriesFrom(__DIR__ . '/../Database/Factories'); + } + + /** + * Register factories. + * + * @param string $path + * @return void + */ + protected function registerEloquentFactoriesFrom($path): void + { + $this->app->make(EloquentFactory::class)->load($path); } }