This repository has been archived on 2025-12-04. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
Caramel-CRM-Backup/database/seeders/DatabaseSeeder.php
T

53 lines
1.4 KiB
PHP
Raw Normal View History

2025-10-20 08:57:51 +02:00
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use App\Models\User;
use App\Models\Customer;
use App\Models\Contact;
use App\Models\Invoice;
use App\Models\LineItem;
class DatabaseSeeder extends Seeder
{
/**
* Seed the application's database.
*/
public function run(): void
{
$this->call([
PaymentTermsSeeder::class,
SettingsTableSeeder::class
]);
User::factory()->create([
'name' => 'Daniel Stock',
'email' => 'daniel.stock@tooloop.de',
'password' => bcrypt('6T0az2JGO5oA'),
]);
// Create customers with contacts
Customer::factory(20)->create()->each(function ($customer) {
// Create a primary contact for each customer
Contact::factory()->create([
'customer_id' => $customer->id,
'is_primary' => true,
]);
// Create additional contacts for each customer
Contact::factory(rand(1, 3))->create([
'customer_id' => $customer->id,
]);
});
// Create invoices
Invoice::factory(20)->create()->each(function ($invoice) {
// Create line items for each invoice
LineItem::factory(rand(5, 10))->create([
'invoice_id' => $invoice->id,
]);
});
}
}