Moved to _dev

This commit is contained in:
2025-09-20 16:11:47 +02:00
parent fb1a8753b7
commit b2ba11fcd3
1670 changed files with 224899 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
<?php
namespace Database\Factories;
use Crater\Models\Address;
use Crater\Models\Customer;
use Crater\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
class AddressFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Address::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'name' => $this->faker->name,
'address_street_1' => $this->faker->streetAddress,
'address_street_2' => $this->faker->streetAddress,
'city' => $this->faker->city,
'state' => $this->faker->state,
'country_id' => 231,
'company_id' => User::find(1)->companies()->first()->id,
'zip' => $this->faker->postcode,
'phone' => $this->faker->phoneNumber,
'fax' => $this->faker->phoneNumber,
'type' => $this->faker->randomElement([Address::BILLING_TYPE, Address::SHIPPING_TYPE]),
'user_id' => User::factory(),
'customer_id' => Customer::factory()
];
}
}

View File

@@ -0,0 +1,32 @@
<?php
namespace Database\Factories;
use Crater\Models\Company;
use Crater\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
class CompanyFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Company::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'unique_hash' => str_random(20),
'name' => $this->faker->name(),
'owner_id' => User::where('role', 'super admin')->first()->id,
'slug' => $this->faker->word
];
}
}

View File

@@ -0,0 +1,31 @@
<?php
namespace Database\Factories;
use Crater\Models\CompanySetting;
use Crater\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
class CompanySettingFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = CompanySetting::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'option' => $this->faker->word,
'value' => $this->faker->word,
'company_id' => User::find(1)->companies()->first()->id,
];
}
}

View File

@@ -0,0 +1,38 @@
<?php
namespace Database\Factories;
use Crater\Models\CustomField;
use Crater\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
class CustomFieldFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = CustomField::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'name' => $this->faker->name,
'label' => $this->faker->name,
'order' => $this->faker->randomDigitNotNull,
'is_required' => $this->faker->randomElement([true, false]),
'model_type' => $this->faker->randomElement(['Customer', 'Invoice', 'Estimate', 'Expense', 'Payment']),
'slug' => function (array $item) {
return clean_slug($item['model_type'], $item['label']);
},
'type' => $this->faker->randomElement(['Text', 'Textarea', 'Phone', 'URL', 'Number','Dropdown' , 'Switch', 'Date', 'DateTime', 'Time']),
'company_id' => User::find(1)->companies()->first()->id,
];
}
}

View File

@@ -0,0 +1,34 @@
<?php
namespace Database\Factories;
use Crater\Models\CustomField;
use Crater\Models\CustomFieldValue;
use Crater\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
class CustomFieldValueFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = CustomFieldValue::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'custom_field_valuable_type' => $this->faker->name ,
'custom_field_valuable_id' => 1,
'type' => $this->faker->name,
'custom_field_id' => CustomField::factory(),
'company_id' => User::find(1)->companies()->first()->id,
];
}
}

View File

@@ -0,0 +1,41 @@
<?php
namespace Database\Factories;
use Crater\Models\Currency;
use Crater\Models\Customer;
use Crater\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Facades\Hash;
class CustomerFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Customer::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'name' => $this->faker->name,
'company_name' => $this->faker->company,
'contact_name' => $this->faker->name,
'prefix' => $this->faker->randomDigitNotNull,
'website' => $this->faker->url,
'enable_portal' => true,
'email' => $this->faker->unique()->safeEmail,
'phone' => $this->faker->phoneNumber,
'company_id' => User::find(1)->companies()->first()->id,
'password' => Hash::make('secret'),
'currency_id' => Currency::find(1)->id,
];
}
}

View File

@@ -0,0 +1,38 @@
<?php
namespace Database\Factories;
use Crater\Models\EmailLog;
use Crater\Models\Estimate;
use Crater\Models\Invoice;
use Crater\Models\Payment;
use Illuminate\Database\Eloquent\Factories\Factory;
class EmailLogFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = EmailLog::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'from' => $this->faker->unique()->safeEmail,
'to' => $this->faker->unique()->safeEmail,
'subject' => $this->faker->sentence,
'body' => $this->faker->text,
'mailable_type' => $this->faker->randomElement([Invoice::class, Estimate::class, Payment::class]),
'mailable_id' => function (array $log) {
return $log['mailable_type']::factory();
},
];
}
}

View File

@@ -0,0 +1,111 @@
<?php
namespace Database\Factories;
use Crater\Models\Currency;
use Crater\Models\Customer;
use Crater\Models\Estimate;
use Crater\Models\User;
use Crater\Services\SerialNumberFormatter;
use Illuminate\Database\Eloquent\Factories\Factory;
class EstimateFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Estimate::class;
public function sent()
{
return $this->state(function (array $attributes) {
return [
'status' => Estimate::STATUS_SENT,
];
});
}
public function viewed()
{
return $this->state(function (array $attributes) {
return [
'status' => Estimate::STATUS_VIEWED,
];
});
}
public function expired()
{
return $this->state(function (array $attributes) {
return [
'status' => Estimate::STATUS_EXPIRED,
];
});
}
public function accepted()
{
return $this->state(function (array $attributes) {
return [
'status' => Estimate::STATUS_ACCEPTED,
];
});
}
public function rejected()
{
return $this->state(function (array $attributes) {
return [
'status' => Estimate::STATUS_REJECTED,
];
});
}
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
$sequenceNumber = (new SerialNumberFormatter())
->setModel(new Estimate())
->setCompany(User::find(1)->companies()->first()->id)
->setNextNumbers();
return [
'estimate_date' => $this->faker->date('Y-m-d', 'now'),
'expiry_date' => $this->faker->date('Y-m-d', 'now'),
'estimate_number' => $sequenceNumber->getNextNumber(),
'sequence_number' => $sequenceNumber->nextSequenceNumber,
'customer_sequence_number' => $sequenceNumber->nextCustomerSequenceNumber,
'reference_number' => $sequenceNumber->getNextNumber(),
'company_id' => User::find(1)->companies()->first()->id,
'status' => Estimate::STATUS_DRAFT,
'template_name' => 'estimate1',
'sub_total' => $this->faker->randomDigitNotNull,
'total' => $this->faker->randomDigitNotNull,
'discount_type' => $this->faker->randomElement(['percentage', 'fixed']),
'discount_val' => function (array $estimate) {
return $estimate['discount_type'] == 'percentage' ? $this->faker->numberBetween($min = 0, $max = 100) : $this->faker->randomDigitNotNull;
},
'discount' => function (array $estimate) {
return $estimate['discount_type'] == 'percentage' ? (($estimate['discount_val'] * $estimate['total']) / 100) : $estimate['discount_val'];
},
'tax_per_item' => 'YES',
'discount_per_item' => 'No',
'tax' => $this->faker->randomDigitNotNull,
'notes' => $this->faker->text(80),
'unique_hash' => str_random(60),
'customer_id' => Customer::factory(),
'exchange_rate' => $this->faker->randomDigitNotNull,
'base_discount_val' => $this->faker->randomDigitNotNull,
'base_sub_total' => $this->faker->randomDigitNotNull,
'base_total' => $this->faker->randomDigitNotNull,
'base_tax' => $this->faker->randomDigitNotNull,
'currency_id' => Currency::find(1)->id,
];
}
}

View File

@@ -0,0 +1,59 @@
<?php
namespace Database\Factories;
use Crater\Models\Estimate;
use Crater\Models\EstimateItem;
use Crater\Models\Item;
use Crater\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
class EstimateItemFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = EstimateItem::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'item_id' => Item::factory(),
'name' => function (array $item) {
return Item::find($item['item_id'])->name;
},
'description' => function (array $item) {
return Item::find($item['item_id'])->description;
},
'price' => function (array $item) {
return Item::find($item['item_id'])->price;
},
'estimate_id' => Estimate::factory(),
'quantity' => $this->faker->randomDigitNotNull,
'company_id' => User::find(1)->companies()->first()->id,
'tax' => $this->faker->randomDigitNotNull,
'total' => function (array $item) {
return ($item['price'] * $item['quantity']);
},
'discount_type' => $this->faker->randomElement(['percentage', 'fixed']),
'discount_val' => function (array $estimate) {
return $estimate['discount_type'] == 'percentage' ? $this->faker->numberBetween($min = 0, $max = 100) : $this->faker->randomDigitNotNull;
},
'discount' => function (array $estimate) {
return $estimate['discount_type'] == 'percentage' ? (($estimate['discount_val'] * $estimate['total']) / 100) : $estimate['discount_val'];
},
'exchange_rate' => $this->faker->randomDigitNotNull,
'base_discount_val' => $this->faker->randomDigitNotNull,
'base_price' => $this->faker->randomDigitNotNull,
'base_total' => $this->faker->randomDigitNotNull,
'base_tax' => $this->faker->randomDigitNotNull,
];
}
}

View File

@@ -0,0 +1,33 @@
<?php
namespace Database\Factories;
use Crater\Models\Currency;
use Crater\Models\ExchangeRateLog;
use Crater\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
class ExchangeRateLogFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = ExchangeRateLog::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'company_id' => Currency::find(1)->id,
'base_currency_id' => User::find(1)->companies()->first()->id,
'currency_id' => Currency::find(4)->id,
'exchange_rate' => $this->faker->randomDigitNotNull
];
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace Database\Factories;
use Crater\Models\ExchangeRateProvider;
use Illuminate\Database\Eloquent\Factories\Factory;
class ExchangeRateProviderFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = ExchangeRateProvider::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'driver' => $this->faker->word,
'key' => str_random(10),
'active' => $this->faker->randomElement([true, false]),
];
}
}

View File

@@ -0,0 +1,31 @@
<?php
namespace Database\Factories;
use Crater\Models\ExpenseCategory;
use Crater\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
class ExpenseCategoryFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = ExpenseCategory::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'name' => $this->faker->word,
'company_id' => User::find(1)->companies()->first()->id,
'description' => $this->faker->text,
];
}
}

View File

@@ -0,0 +1,41 @@
<?php
namespace Database\Factories;
use Crater\Models\Currency;
use Crater\Models\Customer;
use Crater\Models\Expense;
use Crater\Models\ExpenseCategory;
use Crater\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
class ExpenseFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Expense::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'expense_date' => $this->faker->date('Y-m-d', 'now'),
'expense_category_id' => ExpenseCategory::factory(),
'company_id' => User::find(1)->companies()->first()->id,
'amount' => $this->faker->randomDigitNotNull,
'notes' => $this->faker->text,
'attachment_receipt' => null,
'customer_id' => Customer::factory(),
'exchange_rate' => $this->faker->randomDigitNotNull,
'base_amount' => $this->faker->randomDigitNotNull,
'currency_id' => Currency::find(1)->id,
];
}
}

View File

@@ -0,0 +1,35 @@
<?php
namespace Database\Factories;
use Crater\Models\FileDisk;
use Illuminate\Database\Eloquent\Factories\Factory;
class FileDiskFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = FileDisk::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'name' => $this->faker->word,
'driver' => 'local',
'set_as_default' => false,
'credentials' => [
'driver' => 'local',
'root' => storage_path('app'),
],
];
}
}

View File

@@ -0,0 +1,127 @@
<?php
namespace Database\Factories;
use Crater\Models\Currency;
use Crater\Models\Customer;
use Crater\Models\Invoice;
use Crater\Models\RecurringInvoice;
use Crater\Models\User;
use Crater\Services\SerialNumberFormatter;
use Illuminate\Database\Eloquent\Factories\Factory;
class InvoiceFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Invoice::class;
public function sent()
{
return $this->state(function (array $attributes) {
return [
'status' => Invoice::STATUS_SENT,
];
});
}
public function viewed()
{
return $this->state(function (array $attributes) {
return [
'status' => Invoice::STATUS_VIEWED,
];
});
}
public function completed()
{
return $this->state(function (array $attributes) {
return [
'status' => Invoice::STATUS_COMPLETED,
];
});
}
public function unpaid()
{
return $this->state(function (array $attributes) {
return [
'status' => Invoice::STATUS_UNPAID,
];
});
}
public function partiallyPaid()
{
return $this->state(function (array $attributes) {
return [
'status' => Invoice::STATUS_PARTIALLY_PAID,
];
});
}
public function paid()
{
return $this->state(function (array $attributes) {
return [
'status' => Invoice::STATUS_PAID,
];
});
}
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
$sequenceNumber = (new SerialNumberFormatter())
->setModel(new Invoice())
->setCompany(User::find(1)->companies()->first()->id)
->setNextNumbers();
return [
'invoice_date' => $this->faker->date('Y-m-d', 'now'),
'due_date' => $this->faker->date('Y-m-d', 'now'),
'invoice_number' => $sequenceNumber->getNextNumber(),
'sequence_number' => $sequenceNumber->nextSequenceNumber,
'customer_sequence_number' => $sequenceNumber->nextCustomerSequenceNumber,
'reference_number' => $sequenceNumber->getNextNumber(),
'template_name' => 'invoice1',
'status' => Invoice::STATUS_DRAFT,
'tax_per_item' => 'NO',
'discount_per_item' => 'NO',
'paid_status' => Invoice::STATUS_UNPAID,
'company_id' => User::find(1)->companies()->first()->id,
'sub_total' => $this->faker->randomDigitNotNull,
'total' => $this->faker->randomDigitNotNull,
'discount_type' => $this->faker->randomElement(['percentage', 'fixed']),
'discount_val' => function (array $invoice) {
return $invoice['discount_type'] == 'percentage' ? $this->faker->numberBetween($min = 0, $max = 100) : $this->faker->randomDigitNotNull;
},
'discount' => function (array $invoice) {
return $invoice['discount_type'] == 'percentage' ? (($invoice['discount_val'] * $invoice['total']) / 100) : $invoice['discount_val'];
},
'tax' => $this->faker->randomDigitNotNull,
'due_amount' => function (array $invoice) {
return $invoice['total'];
},
'notes' => $this->faker->text(80),
'unique_hash' => str_random(60),
'customer_id' => Customer::factory(),
'recurring_invoice_id' => RecurringInvoice::factory(),
'exchange_rate' => $this->faker->randomDigitNotNull,
'base_discount_val' => $this->faker->randomDigitNotNull,
'base_sub_total' => $this->faker->randomDigitNotNull,
'base_total' => $this->faker->randomDigitNotNull,
'base_tax' => $this->faker->randomDigitNotNull,
'base_due_amount' => $this->faker->randomDigitNotNull,
'currency_id' => Currency::find(1)->id,
];
}
}

View File

@@ -0,0 +1,59 @@
<?php
namespace Database\Factories;
use Crater\Models\InvoiceItem;
use Crater\Models\Item;
use Crater\Models\RecurringInvoice;
use Crater\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
class InvoiceItemFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = InvoiceItem::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'item_id' => Item::factory(),
'name' => function (array $item) {
return Item::find($item['item_id'])->name;
},
'description' => function (array $item) {
return Item::find($item['item_id'])->description;
},
'price' => function (array $item) {
return Item::find($item['item_id'])->price;
},
'company_id' => User::find(1)->companies()->first()->id,
'quantity' => $this->faker->randomDigitNotNull,
'total' => function (array $item) {
return ($item['price'] * $item['quantity']);
},
'discount_type' => $this->faker->randomElement(['percentage', 'fixed']),
'discount_val' => function (array $invoice) {
return $invoice['discount_type'] == 'percentage' ? $this->faker->numberBetween($min = 0, $max = 100) : $this->faker->randomDigitNotNull;
},
'discount' => function (array $invoice) {
return $invoice['discount_type'] == 'percentage' ? (($invoice['discount_val'] * $invoice['total']) / 100) : $invoice['discount_val'];
},
'tax' => $this->faker->randomDigitNotNull,
'recurring_invoice_id' => RecurringInvoice::factory(),
'exchange_rate' => $this->faker->randomDigitNotNull,
'base_discount_val' => $this->faker->randomDigitNotNull,
'base_price' => $this->faker->randomDigitNotNull,
'base_total' => $this->faker->randomDigitNotNull,
'base_tax' => $this->faker->randomDigitNotNull,
];
}
}

View File

@@ -0,0 +1,38 @@
<?php
namespace Database\Factories;
use Crater\Models\Currency;
use Crater\Models\Item;
use Crater\Models\Unit;
use Crater\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
class ItemFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Item::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'name' => $this->faker->name,
'description' => $this->faker->text,
'company_id' => User::find(1)->companies()->first()->id,
'price' => $this->faker->randomDigitNotNull,
'unit_id' => Unit::factory(),
'creator_id' => User::where('role', 'super admin')->first()->company_id,
'currency_id' => Currency::find(1)->id,
'tax_per_item' => $this->faker->randomElement([true, false])
];
}
}

View File

@@ -0,0 +1,32 @@
<?php
namespace Database\Factories;
use Crater\Models\Note;
use Crater\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
class NoteFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Note::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'type' => $this->faker->randomElement(['Invoice', 'Estimate', 'Payment']),
'name' => $this->faker->word,
'notes' => $this->faker->text,
'company_id' => User::find(1)->companies()->first()->id,
];
}
}

View File

@@ -0,0 +1,49 @@
<?php
namespace Database\Factories;
use Crater\Models\Currency;
use Crater\Models\Customer;
use Crater\Models\Payment;
use Crater\Models\PaymentMethod;
use Crater\Models\User;
use Crater\Services\SerialNumberFormatter;
use Illuminate\Database\Eloquent\Factories\Factory;
class PaymentFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Payment::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
$sequenceNumber = (new SerialNumberFormatter())
->setModel(new Payment())
->setCompany(User::find(1)->companies()->first()->id)
->setNextNumbers();
return [
'company_id' => User::find(1)->companies()->first()->id,
'payment_date' => $this->faker->date('Y-m-d', 'now'),
'notes' => $this->faker->text(80),
'amount' => $this->faker->randomDigitNotNull,
'sequence_number' => $sequenceNumber->nextSequenceNumber,
'customer_sequence_number' => $sequenceNumber->nextCustomerSequenceNumber,
'payment_number' => $sequenceNumber->getNextNumber(),
'unique_hash' => str_random(60),
'payment_method_id' => PaymentMethod::find(1)->id,
'customer_id' => Customer::factory(),
'base_amount' => $this->faker->randomDigitNotNull,
'currency_id' => Currency::find(1)->id,
];
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace Database\Factories;
use Crater\Models\PaymentMethod;
use Crater\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
class PaymentMethodFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = PaymentMethod::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'name' => $this->faker->name,
'company_id' => User::find(1)->companies()->first()->id,
];
}
}

View File

@@ -0,0 +1,47 @@
<?php
namespace Database\Factories;
use Crater\Models\Customer;
use Crater\Models\RecurringInvoice;
use Crater\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
class RecurringInvoiceFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = RecurringInvoice::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'starts_at' => $this->faker->iso8601(),
'send_automatically' => false,
'status' => $this->faker->randomElement(['COMPLETED', 'ON_HOLD', 'ACTIVE']),
'tax_per_item' => 'NO',
'discount_per_item' => 'NO',
'sub_total' => $this->faker->randomDigitNotNull,
'total' => $this->faker->randomDigitNotNull,
'tax' => $this->faker->randomDigitNotNull,
'due_amount' => $this->faker->randomDigitNotNull,
'discount' => $this->faker->randomDigitNotNull,
'discount_val' => $this->faker->randomDigitNotNull,
'customer_id' => Customer::factory(),
'company_id' => User::find(1)->companies()->first()->id,
'frequency' => '* * 18 * *',
'limit_by' => $this->faker->randomElement(['NONE', 'COUNT', 'DATE']),
'limit_count' => $this->faker->randomDigit,
'limit_date' => $this->faker->date(),
'exchange_rate' => $this->faker->randomDigitNotNull
];
}
}

View File

@@ -0,0 +1,42 @@
<?php
namespace Database\Factories;
use Crater\Models\Currency;
use Crater\Models\Tax;
use Crater\Models\TaxType;
use Crater\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
class TaxFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Tax::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'tax_type_id' => TaxType::factory(),
'percent' => function (array $item) {
return TaxType::find($item['tax_type_id'])->percent;
},
'name' => function (array $item) {
return TaxType::find($item['tax_type_id'])->name;
},
'company_id' => User::find(1)->companies()->first()->id,
'amount' => $this->faker->randomDigitNotNull,
'compound_tax' => $this->faker->randomDigitNotNull,
'base_amount' => $this->faker->randomDigitNotNull,
'currency_id' => Currency::where('name', 'US Dollar')->first()->id,
];
}
}

View File

@@ -0,0 +1,34 @@
<?php
namespace Database\Factories;
use Crater\Models\TaxType;
use Crater\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
class TaxTypeFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = TaxType::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'name' => $this->faker->word,
'company_id' => User::find(1)->companies()->first()->id,
'percent' => $this->faker->numberBetween($min = 0, $max = 100),
'description' => $this->faker->text,
'compound_tax' => 0,
'collective_tax' => 0,
];
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace Database\Factories;
use Crater\Models\Unit;
use Crater\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
class UnitFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Unit::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'name' => $this->faker->name,
'company_id' => User::find(1)->companies()->first()->id,
];
}
}

View File

@@ -0,0 +1,39 @@
<?php
namespace Database\Factories;
use Crater\Models\Currency;
use Crater\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Facades\Hash;
class UserFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = User::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'name' => $this->faker->name,
'company_name' => $this->faker->company,
'contact_name' => $this->faker->name,
'website' => $this->faker->url,
'enable_portal' => true,
'email' => $this->faker->unique()->safeEmail,
'phone' => $this->faker->phoneNumber,
'role' => 'super admin',
'password' => Hash::make('secret'),
'currency_id' => Currency::first()->id,
];
}
}