Locations

This commit is contained in:
David Bomba
2025-02-21 10:33:41 +11:00
parent d4662c808e
commit 0265bc1603
24 changed files with 1488 additions and 89 deletions

View File

@@ -0,0 +1,41 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
use Str;
class LocationFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'name' => $this->faker->company(),
'custom_value1' => $this->faker->dateTime(),
'custom_value2' => $this->faker->colorName(),
'custom_value3' => $this->faker->word(),
'custom_value4' => $this->faker->email(),
'address1' => $this->faker->buildingNumber(),
'address2' => $this->faker->streetAddress(),
'city' => $this->faker->city(),
'state' => $this->faker->state(),
'postal_code' => $this->faker->postcode(),
'country_id' => 4,
];
}
}

View File

@@ -0,0 +1,52 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('locations', function (Blueprint $table) {
$table->id();
$table->unsignedInteger('user_id');
$table->unsignedInteger('client_id')->nullable()->index();
$table->unsignedInteger('vendor_id')->nullable()->index();
$table->unsignedInteger('company_id')->index();
$table->string('name')->nullable();
$table->string('address1')->nullable();
$table->string('address2')->nullable();
$table->string('city')->nullable();
$table->string('state')->nullable();
$table->string('postal_code')->nullable();
$table->boolean('is_deleted')->default(false);
$table->unsignedInteger('country_id')->nullable();
$table->text('custom_value1')->nullable();
$table->text('custom_value2')->nullable();
$table->text('custom_value3')->nullable();
$table->text('custom_value4')->nullable();
$table->softDeletes('deleted_at', 6);
$table->timestamps(6);
$table->foreign('client_id')->references('id')->on('clients')->onDelete('cascade')->onUpdate('cascade');
$table->foreign('vendor_id')->references('id')->on('vendors')->onDelete('cascade')->onUpdate('cascade');
$table->foreign('company_id')->references('id')->on('companies')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
//
}
};