Re-worked seeders
parent
2361ec0b88
commit
e79d1839fe
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Contact;
|
||||
use App\Models\Customer;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class ContactSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
foreach (Customer::all() as $customer) {
|
||||
if ($customer->company_name == 'Genumark') {
|
||||
$customer->contacts()->createMany([
|
||||
[
|
||||
'first_name' => 'Tammy',
|
||||
'last_name' => 'Bookbinder',
|
||||
'email' => 'tbookbinder@genumark.com',
|
||||
'phone' => '+1 778 229 5668',
|
||||
],
|
||||
[
|
||||
'first_name' => 'Kathlyn',
|
||||
'last_name' => 'Wood',
|
||||
'email' => 'kwood@genumark.com',
|
||||
'phone' => '+1 604 294 2376',
|
||||
'notes' => 'Always CC, unless SOF order',
|
||||
],
|
||||
[
|
||||
'first_name' => 'Jane',
|
||||
'last_name' => 'Wellman',
|
||||
'email' => 'jwellman@genumark.com',
|
||||
'phone' => '+1 604 742 5584',
|
||||
'notes' => 'Deals with SOF orders',
|
||||
],
|
||||
[
|
||||
'first_name' => 'Trisha',
|
||||
'last_name' => 'Miller',
|
||||
'email' => 'tmiller@genumark.com',
|
||||
'phone' => '+1 604 802 8486',
|
||||
],
|
||||
[
|
||||
'first_name' => 'Brenda',
|
||||
'last_name' => 'Kuepfer',
|
||||
'email' => 'bkuepfer@genumark.com',
|
||||
'phone' => '+1 604 305 5002',
|
||||
],
|
||||
]);
|
||||
} else {
|
||||
Contact::factory(rand(1, 4))->for($customer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Order;
|
||||
use App\Models\OrderProduct;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class OrderProductSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
foreach (Order::all() as $order) {
|
||||
OrderProduct::factory(rand(1, 3), ['order_id' => $order->id])->create();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Customer;
|
||||
use App\Models\Order;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class OrderSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
foreach (Customer::all() as $customer) {
|
||||
Order::factory(rand(2, 10), ['customer_id' => $customer])->create();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Order;
|
||||
use App\Models\ProductService;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class ProductServiceSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
foreach (Order::all() as $order) {
|
||||
ProductService::factory(rand(1, 4), ['order_id' => $order->id])->create();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\OrderProduct;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class ProductSizeSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$sizes = ['xs', 's', 'm', 'l', 'xl', '2xl', '3xl'];
|
||||
|
||||
foreach (OrderProduct::all() as $service) {
|
||||
foreach ($sizes as $size) {
|
||||
if (rand(0, 1)) {
|
||||
$service->productSizes()->create([
|
||||
'size' => $size,
|
||||
'amount' => ceil(rand(1, 200) / 10) * 10,
|
||||
'order_product_id' => $service->id,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\ProductService;
|
||||
use App\Models\ServiceFile;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class ServiceFileSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
foreach (ProductService::all() as $product) {
|
||||
$file = ServiceFile::factory()->create();
|
||||
$file->productServices()->save($product);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Customer;
|
||||
use App\Models\ShippingEntry;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class ShippingEntrySeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
foreach (Customer::all() as $customer) {
|
||||
ShippingEntry::factory(5, ['customer_id' => $customer->id])->create();
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
Loading…
Reference in New Issue