diff --git a/app/Http/Controllers/ContactController.php b/app/Http/Controllers/ContactController.php index 18af99a..c562d58 100644 --- a/app/Http/Controllers/ContactController.php +++ b/app/Http/Controllers/ContactController.php @@ -12,6 +12,7 @@ public function index() return [ 'id' => $contact->id, 'customerId' => $contact->customer_id, + 'salutation' => $contact->salutation, 'firstName' => $contact->first_name, 'lastName' => $contact->last_name, 'email' => $contact->email, @@ -36,6 +37,7 @@ public function show($id) return [ 'id' => $contact->id, 'customerId' => $contact->customer_id, + 'salutation' => $contact->salutation, 'firstName' => $contact->first_name, 'lastName' => $contact->last_name, 'email' => $contact->email, @@ -51,4 +53,4 @@ public function show($id) ] : null, ]; } -} \ No newline at end of file +} diff --git a/app/Http/Controllers/InvoiceController.php b/app/Http/Controllers/InvoiceController.php index ad6f445..4b4766e 100644 --- a/app/Http/Controllers/InvoiceController.php +++ b/app/Http/Controllers/InvoiceController.php @@ -344,6 +344,7 @@ public function store(Request $request) 'billingData.billingAddress.city' => 'nullable|string', 'billingData.billingAddress.postalCode' => 'nullable|string', 'billingData.billingAddress.countryCode' => 'nullable|string', + 'billingData.contactSalutation' => 'nullable|string', 'billingData.contactFirstName' => 'nullable|string', 'billingData.contactLastName' => 'nullable|string', 'billingData.paymentTerms' => 'nullable|array', @@ -428,6 +429,7 @@ public function update(Request $request, $id) 'billingData.billingAddress.city' => 'nullable|string', 'billingData.billingAddress.postalCode' => 'nullable|string', 'billingData.billingAddress.countryCode' => 'nullable|string', + 'billingData.contactSalutation' => 'nullable|string', 'billingData.contactFirstName' => 'nullable|string', 'billingData.contactLastName' => 'nullable|string', 'billingData.paymentTerms' => 'nullable|array', diff --git a/app/Models/Contact.php b/app/Models/Contact.php index 15e0a60..04e2a99 100644 --- a/app/Models/Contact.php +++ b/app/Models/Contact.php @@ -11,6 +11,7 @@ class Contact extends Model protected $fillable = [ 'customer_id', + 'salutation', 'first_name', 'last_name', 'email', diff --git a/database/factories/ContactFactory.php b/database/factories/ContactFactory.php index c67d7d6..631c424 100644 --- a/database/factories/ContactFactory.php +++ b/database/factories/ContactFactory.php @@ -20,9 +20,12 @@ public function definition() $avatar = "https://i.pravatar.cc/128?img={$randomImageId}"; } + $gender = rand(0, 9) >= 5 ? 'female' : 'male'; + return [ - 'first_name' => $this->faker->firstName(), - 'last_name' => $this->faker->lastName(), + 'salutation' => $this->faker->title($gender), + 'first_name' => $this->faker->firstName($gender), + 'last_name' => $this->faker->lastName($gender), 'email' => $this->faker->unique()->safeEmail(), 'phone' => $this->faker->phoneNumber(), 'position' => $this->faker->jobTitle(), diff --git a/database/migrations/2025_10_06_122048_create_contacts_table.php b/database/migrations/2025_10_06_122048_create_contacts_table.php index c74cd17..bd5f75e 100644 --- a/database/migrations/2025_10_06_122048_create_contacts_table.php +++ b/database/migrations/2025_10_06_122048_create_contacts_table.php @@ -11,6 +11,7 @@ public function up() Schema::create('contacts', function (Blueprint $table) { $table->id(); $table->foreignId('customer_id')->constrained()->onDelete('cascade'); + $table->string('salutation', 20); $table->string('first_name', 50); $table->string('last_name', 50); $table->string('email', 100)->nullable(); diff --git a/resources/js/pages/Invoices.vue b/resources/js/pages/Invoices.vue index 7edf6d0..41af0d3 100644 --- a/resources/js/pages/Invoices.vue +++ b/resources/js/pages/Invoices.vue @@ -120,6 +120,7 @@ const saveInvoice = async (updatedInvoice: Invoice) => { companyName: updatedInvoice.billingData?.companyName, vatId: updatedInvoice.billingData?.vatId, billingAddress: updatedInvoice.billingData?.billingAddress, + contactSalutation: updatedInvoice.billingData?.contactSalutation, contactFirstName: updatedInvoice.billingData?.contactFirstName, contactLastName: updatedInvoice.billingData?.contactLastName, paymentTerms: updatedInvoice.billingData?.paymentTerms diff --git a/resources/js/types/index.d.ts b/resources/js/types/index.d.ts index 852520f..4919539 100644 --- a/resources/js/types/index.d.ts +++ b/resources/js/types/index.d.ts @@ -86,6 +86,7 @@ export type ContactType = Contact export function newContact(): Contact { return { id: 0, + salutation: '', firstName: '', lastName: '', email: '', @@ -146,6 +147,7 @@ export interface Invoice { companyName: string | null; vatId: string | null; billingAddress: Address | null; + contactSalutation: string | null; contactFirstName: string | null; contactLastName: string | null; paymentTerms: PaymentTerms | null; @@ -181,6 +183,7 @@ export function newBillingData() { companyName: "", vatId: "", billingAddress: newAddress(), + contactSalutation: "", contactFirstName: "", contactLastName: "", paymentTerms: newPaymentTerms() diff --git a/resources/views/mail/invoices/reminder.blade.php b/resources/views/mail/invoices/reminder.blade.php index a8728f5..41c93de 100644 --- a/resources/views/mail/invoices/reminder.blade.php +++ b/resources/views/mail/invoices/reminder.blade.php @@ -178,7 +178,7 @@
|
- Hallo {{ $invoice['billingData']['contactSalutation'] ?? '' }} {{ $invoice['billingData']['contactLastName'] }}, +Hallo {{ $invoice['billingData']['contactSalutation'] ?? 'Herr/Frau' }} {{ $invoice['billingData']['contactLastName'] }}, uns ist aufgefallen, dass die hier aufgeführten Rechnungsbeträge noch nicht beglichen wurden. |
|
- Hallo {{ $offer['contact']['salutation'] ?? '' }} {{ + Hallo {{ $offer['contact']['salutation'] ?? 'Herr/Frau' }} {{ $offer['contact']['lastName'] }}, wir bedanken uns herzlich für Ihren Auftrag und bestätigen Ihnen hiermit den Eingang und die Annahme Ihres Auftrags vom {{ diff --git a/routes/api.php b/routes/api.php index 9209845..c4e91ac 100644 --- a/routes/api.php +++ b/routes/api.php @@ -28,11 +28,11 @@ Route::get('/invoices/{id}/remind', function ($id) { $invoice = InvoiceController::single($id); - Mail::to('daniel@vollstock.de')->send(new Reminder($invoice)); - // return new Reminder($invoice); + // Mail::to('daniel@vollstock.de')->send(new Reminder($invoice)); + return new Reminder($invoice); }); -Route::get('/offers/{id}/confirmation', function ($id) { +Route::get('/offers/{id}/confirm', function ($id) { // $offer = offerController::single($id); $offer = [ 'nr' => 0, @@ -52,23 +52,23 @@ ], 'contact' => [ 'salutation' => 'Frau', - 'firstName' => '', - 'lastName' => '', + 'firstName' => 'Claudia', + 'lastName' => 'Mustermann', 'email' => '', 'phone' => '', 'position' => null, 'isPrimary' => false, 'avatar' => null, ], - 'totalAmount' => '13575.88', - 'title' => "", + 'totalAmount' => '84.033', + 'title' => "Angebots-Titel", 'text' => '', 'items' => [], 'paymentTerms' => [ 'name' => 'onReceipt', 'description' => 'Bei Rechnungserhalt', 'isFixed' => true, - 'days' => null, + 'days' => 14, ] ]; |