Add initial Code
This commit is contained in:
@@ -0,0 +1 @@
|
||||
*.sqlite*
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class ContactFactory extends Factory
|
||||
{
|
||||
protected $model = \App\Models\Contact::class;
|
||||
|
||||
public function definition()
|
||||
{
|
||||
// 30% chance of having an avatar, 70% chance of having null
|
||||
$hasAvatar = $this->faker->boolean(30);
|
||||
|
||||
$avatar = null;
|
||||
if ($hasAvatar) {
|
||||
// Generate a random image ID between 1 and 70 (pravatar.cc has 70 default images)
|
||||
$randomImageId = $this->faker->numberBetween(1, 70);
|
||||
$avatar = "https://i.pravatar.cc/128?img={$randomImageId}";
|
||||
}
|
||||
|
||||
return [
|
||||
'first_name' => $this->faker->firstName(),
|
||||
'last_name' => $this->faker->lastName(),
|
||||
'email' => $this->faker->unique()->safeEmail(),
|
||||
'phone' => $this->faker->phoneNumber(),
|
||||
'position' => $this->faker->jobTitle(),
|
||||
'is_primary' => $this->faker->boolean(30),
|
||||
'avatar' => $avatar,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
use App\Models\PaymentTerms;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class CustomerFactory extends Factory
|
||||
{
|
||||
protected $model = \App\Models\Customer::class;
|
||||
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'type' => $this->faker->randomElement(['private', 'business']),
|
||||
'company_name' => $this->faker->company(),
|
||||
'vat_id' => $this->faker->numerify('DE##########'),
|
||||
'tax_id' => $this->faker->numerify('DE##########'),
|
||||
'global_id' => $this->faker->numerify('############'),
|
||||
'legal_registration_id' => $this->faker->numerify('##########'),
|
||||
'email' => $this->faker->unique()->safeEmail(),
|
||||
'phone' => $this->faker->phoneNumber(),
|
||||
'billing_address' => [
|
||||
'line_one' => $this->faker->streetAddress(),
|
||||
'line_two' => '',
|
||||
'city' => $this->faker->city(),
|
||||
'postal_code' => $this->faker->postcode(),
|
||||
'country_code' => 'DE',
|
||||
],
|
||||
'payment_terms_id' => PaymentTerms::where('name', 'daysAfterInvoice')->first()->id,
|
||||
'logo' => null,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Customer;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use App\Models\LineItem;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Invoice>
|
||||
*/
|
||||
class InvoiceFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
$payment_status = $this->faker->randomElement(['draft', 'issued', 'paid', 'due', 'reminded']);
|
||||
|
||||
return [
|
||||
'nr' => ($payment_status == 'draft') ? null : $this->faker->unique()->numerify('RE-###'),
|
||||
'invoice_date' => $this->faker->date(),
|
||||
'due_date' => $this->faker->date(),
|
||||
'service_start_date' => $this->faker->date(),
|
||||
'service_end_date' => $this->faker->date(),
|
||||
'is_recurring' => $this->faker->boolean(30),
|
||||
'is_partial_service' => $this->faker->boolean(30),
|
||||
'customer_id' => Customer::factory(),
|
||||
'payment_status' => $payment_status,
|
||||
'total_amount' => $this->faker->randomFloat(2, 100, 1000),
|
||||
'title' => $this->faker->text(50),
|
||||
'text' => $this->faker->paragraph(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the factory to create related line items after creating an invoice.
|
||||
*/
|
||||
public function configure()
|
||||
{
|
||||
return $this->afterCreating(function ($invoice) {
|
||||
LineItem::factory(rand(2, 5))->create([
|
||||
'invoice_id' => $invoice->id,
|
||||
]);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class LineItemFactory extends Factory
|
||||
{
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'position' => $this->faker->numberBetween(1, 10),
|
||||
'title' => $this->faker->words(3, true),
|
||||
'description' => $this->faker->sentence(),
|
||||
'quantity' => $this->faker->numberBetween(1, 10),
|
||||
'unit' => $this->faker->randomElement(['Stück', 'Stunden', 'Tage', 'pauschal']),
|
||||
'price' => $this->faker->randomFloat(2, 10, 500),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class PaymentTermsFactory extends Factory
|
||||
{
|
||||
protected $model = \App\Models\PaymentTerms::class;
|
||||
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'name' => $this->faker->unique()->word(),
|
||||
'description' => $this->faker->sentence(),
|
||||
'is_fixed' => $this->faker->boolean(),
|
||||
'days' => $this->faker->numberBetween(7, 60),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User>
|
||||
*/
|
||||
class UserFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The current password being used by the factory.
|
||||
*/
|
||||
protected static ?string $password;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'name' => fake()->name(),
|
||||
'email' => fake()->unique()->safeEmail(),
|
||||
'email_verified_at' => now(),
|
||||
'password' => static::$password ??= Hash::make('password'),
|
||||
'avatar' => null,
|
||||
'remember_token' => Str::random(10),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the model's email address should be unverified.
|
||||
*/
|
||||
public function unverified(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'email_verified_at' => null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
<?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('users', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('email')->unique();
|
||||
$table->timestamp('email_verified_at')->nullable();
|
||||
$table->string('password');
|
||||
$table->string('avatar')->nullable();
|
||||
$table->rememberToken();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('password_reset_tokens', function (Blueprint $table) {
|
||||
$table->string('email')->primary();
|
||||
$table->string('token');
|
||||
$table->timestamp('created_at')->nullable();
|
||||
});
|
||||
|
||||
Schema::create('sessions', function (Blueprint $table) {
|
||||
$table->string('id')->primary();
|
||||
$table->foreignId('user_id')->nullable()->index();
|
||||
$table->string('ip_address', 45)->nullable();
|
||||
$table->text('user_agent')->nullable();
|
||||
$table->longText('payload');
|
||||
$table->integer('last_activity')->index();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('users');
|
||||
Schema::dropIfExists('password_reset_tokens');
|
||||
Schema::dropIfExists('sessions');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,35 @@
|
||||
<?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('cache', function (Blueprint $table) {
|
||||
$table->string('key')->primary();
|
||||
$table->mediumText('value');
|
||||
$table->integer('expiration');
|
||||
});
|
||||
|
||||
Schema::create('cache_locks', function (Blueprint $table) {
|
||||
$table->string('key')->primary();
|
||||
$table->string('owner');
|
||||
$table->integer('expiration');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('cache');
|
||||
Schema::dropIfExists('cache_locks');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,57 @@
|
||||
<?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('jobs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('queue')->index();
|
||||
$table->longText('payload');
|
||||
$table->unsignedTinyInteger('attempts');
|
||||
$table->unsignedInteger('reserved_at')->nullable();
|
||||
$table->unsignedInteger('available_at');
|
||||
$table->unsignedInteger('created_at');
|
||||
});
|
||||
|
||||
Schema::create('job_batches', function (Blueprint $table) {
|
||||
$table->string('id')->primary();
|
||||
$table->string('name');
|
||||
$table->integer('total_jobs');
|
||||
$table->integer('pending_jobs');
|
||||
$table->integer('failed_jobs');
|
||||
$table->longText('failed_job_ids');
|
||||
$table->mediumText('options')->nullable();
|
||||
$table->integer('cancelled_at')->nullable();
|
||||
$table->integer('created_at');
|
||||
$table->integer('finished_at')->nullable();
|
||||
});
|
||||
|
||||
Schema::create('failed_jobs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('uuid')->unique();
|
||||
$table->text('connection');
|
||||
$table->text('queue');
|
||||
$table->longText('payload');
|
||||
$table->longText('exception');
|
||||
$table->timestamp('failed_at')->useCurrent();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('jobs');
|
||||
Schema::dropIfExists('job_batches');
|
||||
Schema::dropIfExists('failed_jobs');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,34 @@
|
||||
<?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::table('users', function (Blueprint $table) {
|
||||
$table->text('two_factor_secret')->after('password')->nullable();
|
||||
$table->text('two_factor_recovery_codes')->after('two_factor_secret')->nullable();
|
||||
$table->timestamp('two_factor_confirmed_at')->after('two_factor_recovery_codes')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropColumn([
|
||||
'two_factor_secret',
|
||||
'two_factor_recovery_codes',
|
||||
'two_factor_confirmed_at',
|
||||
]);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,37 @@
|
||||
<?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()
|
||||
{
|
||||
Schema::create('customers', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->enum('type', ['private', 'business']);
|
||||
$table->string('company_name', 100)->nullable();
|
||||
$table->string('vat_id', 50)->nullable();
|
||||
$table->string('tax_id', 50)->nullable(); // Tax identification number
|
||||
$table->string('global_id', 50)->nullable(); // Global Location Number (GLN)
|
||||
$table->string('legal_registration_id', 50)->nullable(); // Legal registration ID
|
||||
$table->string('email', 100)->unique();
|
||||
$table->string('phone', 20)->nullable();
|
||||
$table->json('billing_address'); // Structured as per ZUGFeRD standard
|
||||
$table->integer('payment_terms')->default(14);
|
||||
$table->enum('status', ['active', 'inactive', 'prospect'])->default('active');
|
||||
$table->text('notes')->nullable();
|
||||
$table->timestamps();
|
||||
// $table->index('email');
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('customers');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
public function up()
|
||||
{
|
||||
Schema::create('customers', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->enum('type', ['private', 'business']);
|
||||
$table->string('company_name', 100)->nullable();
|
||||
$table->string('vat_id', 50)->nullable();
|
||||
$table->string('tax_id', 50)->nullable();
|
||||
$table->string('global_id', 50)->nullable();
|
||||
$table->string('legal_registration_id', 50)->nullable();
|
||||
$table->string('email', 100)->nullable();
|
||||
$table->string('phone', 20)->nullable();
|
||||
$table->json('billing_address')->nullable();
|
||||
$table->foreignId('payment_terms_id')->constrained()->default(3); // Standard-Zahlungsziel: 14 Tage
|
||||
$table->enum('status', ['active', 'inactive', 'prospect'])->default('active');
|
||||
$table->text('notes')->nullable();
|
||||
$table->string('logo')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('customers');
|
||||
}
|
||||
};
|
||||
@@ -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 {
|
||||
public function up()
|
||||
{
|
||||
Schema::create('payment_terms', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name', 50)->unique();
|
||||
$table->string('description', 255)->nullable();
|
||||
$table->boolean('is_fixed')->default(false);
|
||||
$table->integer('days')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
// Fügen Sie Standard-Zahlungsziele hinzu
|
||||
DB::table('payment_terms')->insert([
|
||||
[
|
||||
'name' => 'prepaid',
|
||||
'description' => 'Vorkasse',
|
||||
'is_fixed' => true,
|
||||
'days' => null,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now()
|
||||
],
|
||||
[
|
||||
'name' => 'onReceipt',
|
||||
'description' => 'Bei Rechnungserhalt',
|
||||
'is_fixed' => true,
|
||||
'days' => null,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now()
|
||||
],
|
||||
[
|
||||
'name' => 'daysAfterInvoice',
|
||||
'description' => 'Zahlungsziel in Tagen',
|
||||
'is_fixed' => false,
|
||||
'days' => 14,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now()
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('payment_terms');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,33 @@
|
||||
<?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('personal_access_tokens', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->morphs('tokenable');
|
||||
$table->text('name');
|
||||
$table->string('token', 64)->unique();
|
||||
$table->text('abilities')->nullable();
|
||||
$table->timestamp('last_used_at')->nullable();
|
||||
$table->timestamp('expires_at')->nullable()->index();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('personal_access_tokens');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,39 @@
|
||||
<?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('invoices', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('nr')->unique()->nullable();
|
||||
$table->date('invoice_date');
|
||||
$table->date('due_date')->nullable();
|
||||
$table->date('service_start_date')->nullable();
|
||||
$table->date('service_end_date')->nullable();
|
||||
$table->boolean('is_recurring')->default(false);
|
||||
$table->boolean('is_partial_service')->default(false);
|
||||
$table->foreignId('customer_id')->constrained()->onDelete('cascade');
|
||||
$table->string('payment_status')->default('draft');
|
||||
$table->decimal('total_amount', 10, 2);
|
||||
$table->text('title')->nullable();
|
||||
$table->text('text')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('invoices');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,34 @@
|
||||
<?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('line_items', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('invoice_id')->constrained()->onDelete('cascade');
|
||||
$table->integer('position')->default(0);
|
||||
$table->string('title')->nullable();
|
||||
$table->string('description')->nullable();
|
||||
$table->integer('quantity')->default(1);
|
||||
$table->string('unit')->default('Stunden');
|
||||
$table->decimal('price', 10, 2)->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('line_items');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::create('contacts', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('customer_id')->constrained()->onDelete('cascade');
|
||||
$table->string('first_name', 50);
|
||||
$table->string('last_name', 50);
|
||||
$table->string('email', 100)->nullable();
|
||||
$table->string('phone', 20)->nullable();
|
||||
$table->string('position', 100)->nullable();
|
||||
$table->boolean('is_primary')->default(false);
|
||||
$table->string('avatar')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('contacts');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
<?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::table('invoices', function (Blueprint $table) {
|
||||
$table->json('billing_data')->nullable()->after('customer_id');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('invoices', function (Blueprint $table) {
|
||||
$table->dropColumn('billing_data');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
<?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('settings', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('invoice_number_format')->default('RE-{number}');
|
||||
$table->integer('invoice_number_start')->default(1);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('settings');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,52 @@
|
||||
<?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,
|
||||
]);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\PaymentTerms;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class PaymentTermsSeeder extends Seeder
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
PaymentTerms::create([
|
||||
'name' => 'prepaid',
|
||||
'description' => 'Vorkasse',
|
||||
'is_fixed' => true,
|
||||
'days' => null
|
||||
]);
|
||||
|
||||
PaymentTerms::create([
|
||||
'name' => 'onReceipt',
|
||||
'is_fixed' => true,
|
||||
'days' => null
|
||||
]);
|
||||
|
||||
PaymentTerms::create([
|
||||
'name' => 'daysAfterInvoice',
|
||||
'description' => 'Zahlungsziel in Tagen',
|
||||
'is_fixed' => false,
|
||||
'days' => 14
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use App\Models\Setting;
|
||||
|
||||
class SettingsTableSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
Setting::firstOrCreate([], [
|
||||
'invoice_number_format' => 'RE-{number}',
|
||||
'invoice_number_start' => 1,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user