Laravel 11 (#84)

* Convert string references to `::class`

PHP 5.5.9 adds the new static `class` property which provides the fully qualified class name. This is preferred over using strings for class names since the `class` property references are checked by PHP.

* Use Faker methods

Accessing Faker properties was deprecated in Faker 1.14.

* Convert route options to fluent methods

Laravel 8 adopts the tuple syntax for controller actions. Since the old options array is incompatible with this syntax, Shift converted them to use modern, fluent methods.

* Adopt class based routes

* Remove default `app` files

* Shift core files

* Streamline config files

* Set new `ENV` variables

* Default new `bootstrap/app.php`

* Re-register HTTP middleware

* Consolidate service providers

* Re-register service providers

* Re-register routes

* Re-register scheduled commands

* Bump Composer dependencies

* Use `<env>` tags for configuration

`<env>` tags have a lower precedence than system environment variables making it easier to overwrite PHPUnit configuration values in additional environments, such a CI.

Review this blog post for more details on configuration precedence when testing Laravel: https://jasonmccreary.me/articles/laravel-testing-configuration-precedence/

* Adopt anonymous migrations

* Rename `password_resets` table

* Convert `$casts` property to method

* Adopt Laravel type hints

* Mark base controller as `abstract`

* Remove `CreatesApplication` testing trait

* Shift cleanup

* Fix shift first issues

* Updating Rules for laravel 11, sanctum config and pint

* Fix Carbon issue on dashboard

* Temporary fix for tests while migration is issue fixed on laravel side

* Carbon needs numerical values, not strings

* Minimum php version

* Fix domain installation step not fetching the correct company_id

* Fix Role Policy wasn't properly registered

---------
This commit is contained in:
mchev
2024-06-05 11:33:52 +02:00
committed by GitHub
parent 72311db1bd
commit 3259173066
656 changed files with 4964 additions and 7944 deletions

View File

@@ -2,10 +2,10 @@
namespace Database\Factories;
use App\Models\Address;
use App\Models\Customer;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use InvoiceShelf\Models\Address;
use InvoiceShelf\Models\Customer;
use InvoiceShelf\Models\User;
class AddressFactory extends Factory
{
@@ -18,22 +18,20 @@ class AddressFactory extends Factory
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
public function definition(): array
{
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,
'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,
'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

@@ -2,9 +2,9 @@
namespace Database\Factories;
use App\Models\Company;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use InvoiceShelf\Models\Company;
use InvoiceShelf\Models\User;
class CompanyFactory extends Factory
{
@@ -17,16 +17,14 @@ class CompanyFactory extends Factory
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
public function definition(): array
{
return [
'unique_hash' => str_random(20),
'name' => $this->faker->name(),
'owner_id' => User::where('role', 'super admin')->first()->id,
'slug' => $this->faker->word,
'slug' => $this->faker->word(),
];
}
}

View File

@@ -2,9 +2,9 @@
namespace Database\Factories;
use App\Models\CompanySetting;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use InvoiceShelf\Models\CompanySetting;
use InvoiceShelf\Models\User;
class CompanySettingFactory extends Factory
{
@@ -17,14 +17,12 @@ class CompanySettingFactory extends Factory
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
public function definition(): array
{
return [
'option' => $this->faker->word,
'value' => $this->faker->word,
'option' => $this->faker->word(),
'value' => $this->faker->word(),
'company_id' => User::find(1)->companies()->first()->id,
];
}

View File

@@ -2,9 +2,9 @@
namespace Database\Factories;
use App\Models\CustomField;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use InvoiceShelf\Models\CustomField;
use InvoiceShelf\Models\User;
class CustomFieldFactory extends Factory
{
@@ -17,15 +17,13 @@ class CustomFieldFactory extends Factory
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
public function definition(): array
{
return [
'name' => $this->faker->name,
'label' => $this->faker->name,
'order' => $this->faker->randomDigitNotNull,
'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) {

View File

@@ -2,10 +2,10 @@
namespace Database\Factories;
use App\Models\CustomField;
use App\Models\CustomFieldValue;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use InvoiceShelf\Models\CustomField;
use InvoiceShelf\Models\CustomFieldValue;
use InvoiceShelf\Models\User;
class CustomFieldValueFactory extends Factory
{
@@ -18,15 +18,13 @@ class CustomFieldValueFactory extends Factory
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
public function definition(): array
{
return [
'custom_field_valuable_type' => $this->faker->name,
'custom_field_valuable_type' => $this->faker->name(),
'custom_field_valuable_id' => 1,
'type' => $this->faker->name,
'type' => $this->faker->name(),
'custom_field_id' => CustomField::factory(),
'company_id' => User::find(1)->companies()->first()->id,
];

View File

@@ -2,11 +2,11 @@
namespace Database\Factories;
use App\Models\Currency;
use App\Models\Customer;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Facades\Hash;
use InvoiceShelf\Models\Currency;
use InvoiceShelf\Models\Customer;
use InvoiceShelf\Models\User;
class CustomerFactory extends Factory
{
@@ -19,20 +19,18 @@ class CustomerFactory extends Factory
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
public function definition(): array
{
return [
'name' => $this->faker->name,
'company_name' => $this->faker->company,
'contact_name' => $this->faker->name,
'prefix' => $this->faker->randomDigitNotNull,
'website' => $this->faker->url,
'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,
'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

@@ -2,11 +2,11 @@
namespace Database\Factories;
use App\Models\EmailLog;
use App\Models\Estimate;
use App\Models\Invoice;
use App\Models\Payment;
use Illuminate\Database\Eloquent\Factories\Factory;
use InvoiceShelf\Models\EmailLog;
use InvoiceShelf\Models\Estimate;
use InvoiceShelf\Models\Invoice;
use InvoiceShelf\Models\Payment;
class EmailLogFactory extends Factory
{
@@ -19,16 +19,14 @@ class EmailLogFactory extends Factory
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
public function definition(): array
{
return [
'from' => $this->faker->unique()->safeEmail,
'to' => $this->faker->unique()->safeEmail,
'subject' => $this->faker->sentence,
'body' => $this->faker->text,
'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

@@ -2,12 +2,12 @@
namespace Database\Factories;
use App\Models\Currency;
use App\Models\Customer;
use App\Models\Estimate;
use App\Models\User;
use App\Services\SerialNumberFormatter;
use Illuminate\Database\Eloquent\Factories\Factory;
use InvoiceShelf\Models\Currency;
use InvoiceShelf\Models\Customer;
use InvoiceShelf\Models\Estimate;
use InvoiceShelf\Models\User;
use InvoiceShelf\Services\SerialNumberFormatter;
class EstimateFactory extends Factory
{
@@ -65,10 +65,8 @@ class EstimateFactory extends Factory
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
public function definition(): array
{
$sequenceNumber = (new SerialNumberFormatter())
->setModel(new Estimate())
@@ -85,26 +83,26 @@ class EstimateFactory extends Factory
'company_id' => User::find(1)->companies()->first()->id,
'status' => Estimate::STATUS_DRAFT,
'template_name' => 'estimate1',
'sub_total' => $this->faker->randomDigitNotNull,
'total' => $this->faker->randomDigitNotNull,
'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;
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,
'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,
'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

@@ -2,11 +2,11 @@
namespace Database\Factories;
use App\Models\Estimate;
use App\Models\EstimateItem;
use App\Models\Item;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use InvoiceShelf\Models\Estimate;
use InvoiceShelf\Models\EstimateItem;
use InvoiceShelf\Models\Item;
use InvoiceShelf\Models\User;
class EstimateItemFactory extends Factory
{
@@ -19,10 +19,8 @@ class EstimateItemFactory extends Factory
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
public function definition(): array
{
return [
'item_id' => Item::factory(),
@@ -36,24 +34,24 @@ class EstimateItemFactory extends Factory
return Item::find($item['item_id'])->price;
},
'estimate_id' => Estimate::factory(),
'quantity' => $this->faker->randomDigitNotNull,
'quantity' => $this->faker->randomDigitNotNull(),
'company_id' => User::find(1)->companies()->first()->id,
'tax' => $this->faker->randomDigitNotNull,
'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;
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,
'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

@@ -2,10 +2,10 @@
namespace Database\Factories;
use App\Models\Currency;
use App\Models\ExchangeRateLog;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use InvoiceShelf\Models\Currency;
use InvoiceShelf\Models\ExchangeRateLog;
use InvoiceShelf\Models\User;
class ExchangeRateLogFactory extends Factory
{
@@ -18,16 +18,14 @@ class ExchangeRateLogFactory extends Factory
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
public function definition(): array
{
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,
'exchange_rate' => $this->faker->randomDigitNotNull(),
];
}
}

View File

@@ -2,8 +2,8 @@
namespace Database\Factories;
use App\Models\ExchangeRateProvider;
use Illuminate\Database\Eloquent\Factories\Factory;
use InvoiceShelf\Models\ExchangeRateProvider;
class ExchangeRateProviderFactory extends Factory
{
@@ -16,13 +16,11 @@ class ExchangeRateProviderFactory extends Factory
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
public function definition(): array
{
return [
'driver' => $this->faker->word,
'driver' => $this->faker->word(),
'key' => str_random(10),
'active' => $this->faker->randomElement([true, false]),
];

View File

@@ -2,9 +2,9 @@
namespace Database\Factories;
use App\Models\ExpenseCategory;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use InvoiceShelf\Models\ExpenseCategory;
use InvoiceShelf\Models\User;
class ExpenseCategoryFactory extends Factory
{
@@ -17,15 +17,13 @@ class ExpenseCategoryFactory extends Factory
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
public function definition(): array
{
return [
'name' => $this->faker->word,
'name' => $this->faker->word(),
'company_id' => User::find(1)->companies()->first()->id,
'description' => $this->faker->text,
'description' => $this->faker->text(),
];
}
}

View File

@@ -2,12 +2,12 @@
namespace Database\Factories;
use App\Models\Currency;
use App\Models\Customer;
use App\Models\Expense;
use App\Models\ExpenseCategory;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use InvoiceShelf\Models\Currency;
use InvoiceShelf\Models\Customer;
use InvoiceShelf\Models\Expense;
use InvoiceShelf\Models\ExpenseCategory;
use InvoiceShelf\Models\User;
class ExpenseFactory extends Factory
{
@@ -20,21 +20,19 @@ class ExpenseFactory extends Factory
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
public function definition(): array
{
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,
'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,
'exchange_rate' => $this->faker->randomDigitNotNull(),
'base_amount' => $this->faker->randomDigitNotNull(),
'currency_id' => Currency::find(1)->id,
];
}

View File

@@ -2,8 +2,8 @@
namespace Database\Factories;
use App\Models\FileDisk;
use Illuminate\Database\Eloquent\Factories\Factory;
use InvoiceShelf\Models\FileDisk;
class FileDiskFactory extends Factory
{
@@ -16,13 +16,11 @@ class FileDiskFactory extends Factory
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
public function definition(): array
{
return [
'name' => $this->faker->word,
'name' => $this->faker->word(),
'driver' => 'local',
'set_as_default' => false,
'credentials' => [

View File

@@ -2,13 +2,13 @@
namespace Database\Factories;
use App\Models\Currency;
use App\Models\Customer;
use App\Models\Invoice;
use App\Models\RecurringInvoice;
use App\Models\User;
use App\Services\SerialNumberFormatter;
use Illuminate\Database\Eloquent\Factories\Factory;
use InvoiceShelf\Models\Currency;
use InvoiceShelf\Models\Customer;
use InvoiceShelf\Models\Invoice;
use InvoiceShelf\Models\RecurringInvoice;
use InvoiceShelf\Models\User;
use InvoiceShelf\Services\SerialNumberFormatter;
class InvoiceFactory extends Factory
{
@@ -75,10 +75,8 @@ class InvoiceFactory extends Factory
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
public function definition(): array
{
$sequenceNumber = (new SerialNumberFormatter())
->setModel(new Invoice())
@@ -98,16 +96,16 @@ class InvoiceFactory extends Factory
'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,
'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;
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,
'tax' => $this->faker->randomDigitNotNull(),
'due_amount' => function (array $invoice) {
return $invoice['total'];
},
@@ -115,12 +113,12 @@ class InvoiceFactory extends Factory
'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,
'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

@@ -2,11 +2,11 @@
namespace Database\Factories;
use App\Models\InvoiceItem;
use App\Models\Item;
use App\Models\RecurringInvoice;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use InvoiceShelf\Models\InvoiceItem;
use InvoiceShelf\Models\Item;
use InvoiceShelf\Models\RecurringInvoice;
use InvoiceShelf\Models\User;
class InvoiceItemFactory extends Factory
{
@@ -19,10 +19,8 @@ class InvoiceItemFactory extends Factory
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
public function definition(): array
{
return [
'item_id' => Item::factory(),
@@ -36,24 +34,24 @@ class InvoiceItemFactory extends Factory
return Item::find($item['item_id'])->price;
},
'company_id' => User::find(1)->companies()->first()->id,
'quantity' => $this->faker->randomDigitNotNull,
'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;
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,
'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,
'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

@@ -2,11 +2,11 @@
namespace Database\Factories;
use App\Models\Currency;
use App\Models\Item;
use App\Models\Unit;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use InvoiceShelf\Models\Currency;
use InvoiceShelf\Models\Item;
use InvoiceShelf\Models\Unit;
use InvoiceShelf\Models\User;
class ItemFactory extends Factory
{
@@ -19,16 +19,14 @@ class ItemFactory extends Factory
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
public function definition(): array
{
return [
'name' => $this->faker->name,
'description' => $this->faker->text,
'name' => $this->faker->name(),
'description' => $this->faker->text(),
'company_id' => User::find(1)->companies()->first()->id,
'price' => $this->faker->randomDigitNotNull,
'price' => $this->faker->randomDigitNotNull(),
'unit_id' => Unit::factory(),
'creator_id' => User::where('role', 'super admin')->first()->company_id,
'currency_id' => Currency::find(1)->id,

View File

@@ -2,9 +2,9 @@
namespace Database\Factories;
use App\Models\Note;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use InvoiceShelf\Models\Note;
use InvoiceShelf\Models\User;
class NoteFactory extends Factory
{
@@ -17,15 +17,13 @@ class NoteFactory extends Factory
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
public function definition(): array
{
return [
'type' => $this->faker->randomElement(['Invoice', 'Estimate', 'Payment']),
'name' => $this->faker->word,
'notes' => $this->faker->text,
'name' => $this->faker->word(),
'notes' => $this->faker->text(),
'company_id' => User::find(1)->companies()->first()->id,
];
}

View File

@@ -2,13 +2,13 @@
namespace Database\Factories;
use App\Models\Currency;
use App\Models\Customer;
use App\Models\Payment;
use App\Models\PaymentMethod;
use App\Models\User;
use App\Services\SerialNumberFormatter;
use Illuminate\Database\Eloquent\Factories\Factory;
use InvoiceShelf\Models\Currency;
use InvoiceShelf\Models\Customer;
use InvoiceShelf\Models\Payment;
use InvoiceShelf\Models\PaymentMethod;
use InvoiceShelf\Models\User;
use InvoiceShelf\Services\SerialNumberFormatter;
class PaymentFactory extends Factory
{
@@ -21,10 +21,8 @@ class PaymentFactory extends Factory
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
public function definition(): array
{
$sequenceNumber = (new SerialNumberFormatter())
->setModel(new Payment())
@@ -35,14 +33,14 @@ class PaymentFactory extends Factory
'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,
'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,
'base_amount' => $this->faker->randomDigitNotNull(),
'currency_id' => Currency::find(1)->id,
];
}

View File

@@ -2,9 +2,9 @@
namespace Database\Factories;
use App\Models\PaymentMethod;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use InvoiceShelf\Models\PaymentMethod;
use InvoiceShelf\Models\User;
class PaymentMethodFactory extends Factory
{
@@ -17,13 +17,11 @@ class PaymentMethodFactory extends Factory
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
public function definition(): array
{
return [
'name' => $this->faker->name,
'name' => $this->faker->name(),
'company_id' => User::find(1)->companies()->first()->id,
];
}

View File

@@ -2,10 +2,10 @@
namespace Database\Factories;
use App\Models\Customer;
use App\Models\RecurringInvoice;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use InvoiceShelf\Models\Customer;
use InvoiceShelf\Models\RecurringInvoice;
use InvoiceShelf\Models\User;
class RecurringInvoiceFactory extends Factory
{
@@ -18,10 +18,8 @@ class RecurringInvoiceFactory extends Factory
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
public function definition(): array
{
return [
'starts_at' => $this->faker->iso8601(),
@@ -29,19 +27,19 @@ class RecurringInvoiceFactory extends Factory
'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,
'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_count' => $this->faker->randomDigit(),
'limit_date' => $this->faker->date(),
'exchange_rate' => $this->faker->randomDigitNotNull,
'exchange_rate' => $this->faker->randomDigitNotNull(),
];
}
}

View File

@@ -2,11 +2,11 @@
namespace Database\Factories;
use App\Models\Currency;
use App\Models\Tax;
use App\Models\TaxType;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use InvoiceShelf\Models\Currency;
use InvoiceShelf\Models\Tax;
use InvoiceShelf\Models\TaxType;
use InvoiceShelf\Models\User;
class TaxFactory extends Factory
{
@@ -19,10 +19,8 @@ class TaxFactory extends Factory
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
public function definition(): array
{
return [
'tax_type_id' => TaxType::factory(),
@@ -33,9 +31,9 @@ class TaxFactory extends Factory
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,
'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

@@ -2,9 +2,9 @@
namespace Database\Factories;
use App\Models\TaxType;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use InvoiceShelf\Models\TaxType;
use InvoiceShelf\Models\User;
class TaxTypeFactory extends Factory
{
@@ -17,16 +17,14 @@ class TaxTypeFactory extends Factory
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
public function definition(): array
{
return [
'name' => $this->faker->word,
'name' => $this->faker->word(),
'company_id' => User::find(1)->companies()->first()->id,
'percent' => $this->faker->numberBetween($min = 0, $max = 100),
'description' => $this->faker->text,
'description' => $this->faker->text(),
'compound_tax' => 0,
'collective_tax' => 0,
];

View File

@@ -2,9 +2,9 @@
namespace Database\Factories;
use App\Models\Unit;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use InvoiceShelf\Models\Unit;
use InvoiceShelf\Models\User;
class UnitFactory extends Factory
{
@@ -17,13 +17,11 @@ class UnitFactory extends Factory
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
public function definition(): array
{
return [
'name' => $this->faker->name,
'name' => $this->faker->name(),
'company_id' => User::find(1)->companies()->first()->id,
];
}

View File

@@ -2,10 +2,10 @@
namespace Database\Factories;
use App\Models\Currency;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Facades\Hash;
use InvoiceShelf\Models\Currency;
use InvoiceShelf\Models\User;
class UserFactory extends Factory
{
@@ -18,19 +18,17 @@ class UserFactory extends Factory
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
public function definition(): array
{
return [
'name' => $this->faker->name,
'company_name' => $this->faker->company,
'contact_name' => $this->faker->name,
'website' => $this->faker->url,
'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,
'email' => $this->faker->unique()->safeEmail(),
'phone' => $this->faker->phoneNumber(),
'role' => 'super admin',
'password' => Hash::make('secret'),
'currency_id' => Currency::first()->id,