Created
January 13, 2022 22:10
-
-
Save NandoKstroNet/dd1e1610b477e38c140b8641ce8f8c67 to your computer and use it in GitHub Desktop.
Factories e Seed Tenant Store em https://codeexperts.com.br
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
\App\Models\Tenant::factory(10) | |
->hasStores(1) | |
->create(); | |
foreach(\App\Models\Store::all() as $store) { | |
$tenantAndStoreIds = ['store_id' => $store->id, 'tenant_id' => $store->tenant_id]; | |
\App\Models\Product::factory(20, $tenantAndStoreIds) | |
->create(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//tenant factory | |
'contract' => $this->faker->uuid, | |
'is_active' => 1 | |
//store factory | |
'name' => $this->faker->word, | |
'description' => $this->faker->sentence, | |
'logo' => $this->faker->imageUrl(180, 180), | |
'cover' => $this->faker->imageUrl(1280, 720), | |
'subdomain' => $this->faker->slug | |
//product factory | |
$nameProduct = $this->faker->word; | |
return [ | |
'name' => $nameProduct, | |
'description' => $this->faker->sentence, | |
'price' => $this->faker->numberBetween(1, 5000), | |
'body' => $this->faker->paragraphs(5, true), | |
'slug' => Str::slug($nameProduct) | |
]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment